我要在URL
地址中創建漂亮的鏈接地址。從URL中刪除子文件夾
比如我有:
mysite.com/language/en/
而且從url
刪除language
文件夾:
mysite.com/en/
我.htaccess
寫道:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^language/(.*)$ /$1 [L,R]
</IfModule>
它工作正常,但mysite.com/en/
應該有mysite.com/language/en/
的內容。現在我有404
錯誤。
我該怎麼辦?
更新(全.htaccess
):
Options All -ExecCGI -Indexes -Includes +FollowSymLinks
# Bad Request
ErrorDocument 400 /error/400.html
# Authorization Required
ErrorDocument 401 /error/401.html
# Forbidden
ErrorDocument 403 /error/403.html
# Not found
ErrorDocument 404 /error/404.html
# Method Not Allowed
ErrorDocument 405 /error/405.html
# Request Timed Out
ErrorDocument 408 /error/408.html
# Request URI Too Long
ErrorDocument 414 /error/414.html
# Internal Server Error
ErrorDocument 500 /error/500.html
# Not Implemented
ErrorDocument 501 /error/501.html
# Bad Gateway
ErrorDocument 502 /error/502.html
# Service Unavailable
ErrorDocument 503 /error/503.html
# Gateway Timeout
ErrorDocument 504 /error/504.html
#Rewrite links
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^language/(.*)$ /$1 [L,R]
</IfModule>
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
<ifModule mod_headers.c>
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200, public"
</FilesMatch>
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
</IfModule>
我相信您應該切換'RewriteRule':(。*)'^重寫規則$ /語言/ $ 1 [L,R]' –
@BogdanKuštan之後,我得到了'mysite.com/language * 1000/en')) –
我有規則緩存內容並壓縮它。 .htaccess是單一的。 –