Redirect all pages to new domain exclude one page with htacces

泄露秘密 提交于 2019-12-13 00:54:50

问题


I try redirect all pages to new domain exclude one page with htacces.

RewriteCond %{REQUEST_URI}!^/onepage.php/
RewriteRule (.*) http://newdomain.com/$1 [R=301,L]

This is working but page onepage.php show internal error 500


回答1:


You can try with either of the following in your .htaccess file:

Example 1: Check the request URI for onepage.php and redirect if it is not being requested:

RewriteEngine on

RewriteCond %{REQUEST_URI} !^/onepage.php [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

Example 2: If onepage.php is being requested, don't do anything. Otherwise, redirect:

RewriteEngine on

RewriteRule ^onepage\.php - [L]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

As you're redirecting everything except for onepage.php, you do not need any other rules in your file. The rules above should be the only ones in there.



来源:https://stackoverflow.com/questions/30029279/redirect-all-pages-to-new-domain-exclude-one-page-with-htacces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!