Fabman22 Fabman22 - 2 months ago 10
PHP Question

Default redirect in mod_rewrite with .htaccess

Simple question... According to this tutorial: URL Rewriting I´d like to make a simple redirect rule. I´m working on my testserver, so the website is in a subdirectory of the domain: http://my-server.de/lcbs . I like to redirect http://my-server.de/lcbs/index to http://my-server.de/lcbs/index.php?page=news&parent=lcbs. So I´m using this rule:

RewriteEngine On
RewriteRule ^lcbs/index?$ lcbs/index.php?page=news&parent=lcbs


Now, when I like to open http://my-server.de/lcbs/index , this error appears:

The requested URL /lcbs/index was not found on this server.


If I change it to following code:

RewriteEngine On
RewriteRule ^index?$ index.php?page=news&parent=lcbs


this error appears:

The requested URL /var/www/lcbs.de/public_html/index.php was not found on this server.


What I´m doing wrong? I think it´s not a big thing...
Thanks!

Answer

Try this:

RewriteEngine On
RewriteBase /lcbs/
RewriteRule ^index$ index.php?page=news&parent=lcbs

or this:

RewriteEngine On
RewriteRule ^lcbs/index$ lcbs/index.php?page=news&parent=lcbs
Comments