嗨一直在寻找年龄并尝试了一些例子,但没有任何工作。我希望我的网址看起来好像位于根目录而不是购买子目录中:
http://www.example.com/buy/*.html
到
http://www.example.com/*.html
RewriteRule ^buy/(.*)$ $1 [L]
继续使页面无法正确重定向。 @Panama Jack
感谢任何想法。
的.htaccess
# non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
AddType application/x-httpd-php .html .htm
# rewrite products to root located
RewriteRule ^buy/(.*)$ $1 [L]
# Remove index.php or index.htm/html from URL requests
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.(php|html?)\ HTTP/
RewriteRule ^([^/]+/)*index\.(html?|php)$ http://www.example.com/$1 [R=301,L]
# GZIP
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/x-javascript application/javascript
# Redirect all index calls
RewriteEngine On
RewriteRule ^index\.(php|html?)$ http://www.example.com/ [R=301,L]
#Custom 404 errors
ErrorDocument 404 /productslinks404.html
答案 0 :(得分:0)
如果/buy/somepage.html
是真实页面,那么如果您需要
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ /buy/$1.html [L]