code_junkie

Redirect rule in .htaccess is taking me to the wrong place

Nov 12th, 2011
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. Redirect 301 /file-name/example.php http://www.mysite.com/file-name/example-001.php
  2. Redirect 301 /section-name/example.php http://www.my-site.com/section-name/example-002.php
  3.  
  4. RewriteEngine on
  5. RewriteCond %{HTTP_HOST} !^www.mysite.com$ [NC]
  6. RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
  7. RewriteCond %{REQUEST_FILENAME} !-f
  8. RewriteRule ^(.+)/(.*)$ hqtemplates/articles.php?file_name=$2 [L]
  9. php_value session.use_only_cookies 1
  10. php_value session.use_trans_sid 0
  11.  
  12. RewriteEngine on
  13. # emulate specific mod_alias Redirect rules
  14. #
  15. # Flags explanation:
  16. # [L] = last rule, stop processing further rules
  17. # [R=301] = 301 Redirect
  18. #
  19. RewriteRule ^file-name/example.php$ http://www.mysite.com/file-name/example-001.php [L,R=301]
  20. RewriteRule ^section-name/example.php$ http://www.my-site.com/section-name/example-002.php [L,R=301]
  21.  
  22. # handle other rewrite requests
  23. RewriteCond %{REQUEST_FILENAME} !-f
  24. RewriteRule ^(.+)/(.*)$ hqtemplates/articles.php?file_name=$2 [L]
  25.  
  26. (2) rewrite 'file-name/example.php' ->
  27. 'hqtemplates/articles.php?file_name=example.php'
  28. (2) strip document_root prefix: /home/test/hqtemplates/articles.php ->
  29. /hqtemplates/articles.php
  30. (1) internal redirect with /hqtemplates/articles.php [INTERNAL REDIRECT]
  31. (1) pass through /home/test/Sites/file-name/example-001.php
Add Comment
Please, Sign In to add comment