Forum Moderators: phranque
The htaccess is read and sort of works.
Imaging I have this url being linked to
[localhost...]
but it seems to redirects to this one
[localhost...]
Now if I turn the rewrite engine off it I just get a 404.
Here is the rewrite rule
rewriteEngine on
rewritebase /
rewriteRule files\/([0-9]+)\.php http:\/\/localhost\/directory\/files\/?c=$1 [L]
Any pointers as to why this might do this when it has worked on numerous times before.
Cheers
Either of the following code fragments is valid. Use the first if you want an external redirect. Use the second if you want an internal rewrite.
RewriteEngine on
RewriteBase /
RewriteRule files/([0-9]+)\.php http://localhost/directory/files/?c=$1 [R=301,L]
RewriteEngine on
RewriteBase /
RewriteRule files/([0-9]+)\.php /directory/files/?c=$1 [L]
For an external redirect, the method (http:) and domain (//localhost) are required. For an internal rewrite, they should not be used. An external redirect sends a redirect response to the browser, requiring it to re-request the page at the new URL, and making this new URL visible in the browser address bar. An internal rewrite simply serves the contents at the substitute filepath when a URL matching the pattern is requested.
I suspect you will want to use the second code fragment if you are using this code to support search-engine-friendly URLs.
Jim
The weird thing is that the rules I had work on the live website, although I do intend to clean up my act.
I do however have a problem with serving multiple sites;
See example here
[webmasterworld.com...]
Multiple sites serve fine but I can have multiple htaccess files. In the end I managed to put the rewtite rules into the httpd.conf file using the
<Directory />
notation within the virtualhost container. It would be nice though not to have to restart the server each time, which is where it was good to have htaccess access.
Is that a simple one to consider.
cheers