我制作了一个.htaccess文件,以使我的网址从http://www.domain.com/ar/?page=article&id=20变为http://www.domain.com/ar/article/20

我到目前为止已经做到了

Options -ExecCGI +Includes -IncludesNOEXEC -Indexes -SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /ar/?page=$1&id=$2 [L]

但是..所有文件(css,js,图像)都坏了..我试图使其尽可能地绝对(通过在每个src的开头添加/)而没有运气。

..如何下载文件?

如何将网址从(?page = contact重定向到ar / contact ..而不是ar / topic / 20 /?page = contact)重定向?

以及如何在我的网址中包含任何其他意外参数?

===============>>#1 票数:0

我不太确定,但是可以尝试一下。

Options +FollowSymLinks
RewriteEngine On
# with html base href in header: <base href="http://<?=$_SERVER['HTTP_HOST']?>/" />
RewriteBase /
# deny rules to url rewrite for specific file types in website root folder
RewriteRule ^/?(.*).(php|css|ico|js|log|png|jpg|gif|jpeg)$ - [L]
# deny rules to url rewrite for folders (if needed)
RewriteRule ^(css|images)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# and the mapping rule. index.php is your basic file for example
# $1 -> ar/ $2 -> article/$3 -> 20
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ index.php?module=$1&page=$2&id=$3 [L]
Options SymLinksIfOwnerMatch

===============>>#2 票数:0

您需要向重写规则添加条件。 尝试这个。

Options -ExecCGI +Includes -IncludesNOEXEC -Indexes -SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_URI} !.*\.(css¦jpg¦gif¦png¦js)
RewriteRule ^([^/]*)/([^/]*)$ /ar/?page=$1&id=$2 [L]

仅当请求的文件没有CSS,JPG,GIF,PNG或JS扩展名时,才会重写URL。

编辑更正了语法错误。

  ask by Khaled Ali translate from so

未解决问题?本站智能推荐: