Url rewrite rules error: The requested URL was not found on this server
Url rewrite rules error: The requested URL was not found on this server
我在我的域文件夹中的 .htaccess
文件中创建规则。
我在服务器上的 url 是:
https://www.everyoneknows.com.my/customer/?loc=dashboard
我想将 url 更改为:
https://www.everyoneknows.com.my/customer/dashboard/
在.htaccess文件中,我写的规则是:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^everyoneknows\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.everyoneknows.com.my/ [R,L]
##External redirect to /customer/dashboard url rules here.
RewriteCond %{QUERY_STRING} ^loc\=dashboard$
RewriteRule ^customer/$ https://www.everyoneknows.com.my/customer/dashboard/? [R=301,L]
并显示错误消息:
Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
希望有人能指导我如何更正我重写的 url 规则。谢谢。
原结果:
已更新 1
您需要一个从旧 URL 到新的重定向规则和一个内部重写规则来处理漂亮 URL:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^everyoneknows\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://www.everyoneknows.com.my%{REQUEST_URI} [R=301,NE,L]
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+(customer)/\?loc=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(customer)/([\w-]+)/?$ /?loc= [L,QSA,NC]
这假设 customer/
子目录中没有 .htaccess。确保在测试此更改之前清除浏览器缓存。
我在我的域文件夹中的 .htaccess
文件中创建规则。
我在服务器上的 url 是:
https://www.everyoneknows.com.my/customer/?loc=dashboard
我想将 url 更改为:
https://www.everyoneknows.com.my/customer/dashboard/
在.htaccess文件中,我写的规则是:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^everyoneknows\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.everyoneknows.com.my/ [R,L]
##External redirect to /customer/dashboard url rules here.
RewriteCond %{QUERY_STRING} ^loc\=dashboard$
RewriteRule ^customer/$ https://www.everyoneknows.com.my/customer/dashboard/? [R=301,L]
并显示错误消息:
Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
希望有人能指导我如何更正我重写的 url 规则。谢谢。
原结果:
已更新 1
您需要一个从旧 URL 到新的重定向规则和一个内部重写规则来处理漂亮 URL:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^everyoneknows\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://www.everyoneknows.com.my%{REQUEST_URI} [R=301,NE,L]
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+(customer)/\?loc=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(customer)/([\w-]+)/?$ /?loc= [L,QSA,NC]
这假设 customer/
子目录中没有 .htaccess。确保在测试此更改之前清除浏览器缓存。