Forum Moderators: phranque
RewriteEngine On# Rewrite old threads to the new urls #
RewriteCond %{QUERY_STRING}!seourl=1$
RewriteCond %{QUERY_STRING} ^t=([0-9]+)$
RewriteCond %{REQUEST_URI}!^(t¦thread)([0-9]+)(((-p)([0-9]+))?)([A-Za-z0-9\-;]+)\.html$
RewriteRule ^showthread\.php$ seourls.php?t=%1 [R=301,L]
# Rewrite old forums to the new urls #
RewriteCond %{QUERY_STRING}!seourl=1$
RewriteCond %{QUERY_STRING} ^f=([0-9]+)$
RewriteCond %{REQUEST_URI}!^(f¦forum)([0-9]+)-([A-Za-z0-9\-;]+)\.html$
RewriteRule ^forumdisplay\.php$ seourls.php?f=%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}!^(showthread¦forumdisplay)\.php$
RewriteRule ^(f¦forum)([0-9]+)-([A-Za-z0-9\-;]+)\.html$ forumdisplay.php?f=$2&seourl=1 [L]
RewriteRule ^(t¦thread)([0-9]+)(((-p)([0-9]+))?)([A-Za-z0-9\-;]+)\.html$
showthread.php?t=$2&page=$6&pp=10&seourl=1 [L]
When I go to www.example.com/dir/showthread.php?t=1 it redirects to /home/fullpath/to/all/the/files/domain.com/lala/seourls.php?t=1
So it's not taking any notice of the relative paths. When I put a RewriteBase / in the rule it redirects www.example.com/dir/showthread.php?t=1 to www.example.com/seourls.php?t=1
Any ideas where I'm going wrong :)?
Internal rewrite:
RewriteRule ^foo\.html$ /bar.php [L]
RewriteRule ^foo.html$ http://www.example.com/bar.php [R=301,L]
Internal rewrite simply changes the internal server filepath from which the content should be served; No client interaction takes place. External redirect sends 301/302 response to client, giving new URL. Client then re-requests content from new URL (Browser address bar will show new URL, search engine spider will update its URL database if 301 is used, 302 currently produces mixed ("sub-optimal") results across search engines, so avoid it).
Examples are for use in .htaccess context.
Jim
Personally, I never rely on 'relative paths' in mod_rewrite; It's too dependent on proper server config, UseCanonicalName, and DocumentRoot settings to work well across multiple commercially-hosted servers. So I always 'root' my substitution URLs, even for internal rewrites, i.e. precede them with a slash.
Jim