我想要一个URL,例如http://localhost/universe/networks/o2/o2_logo.gif并执行以下操作:
If it begins with /universe/ Strip /universe/ from it to become /networks/o2/o2_logo.gif Check if this exists in %{DOCUMENT_ROOT}/networks/o2/o2_logo.gif If so, silently rewrite the request to this file.
如果我使用以下规则:
RewriteCond %{REQUEST_URI} ^/universe/ RewriteRule ^(.*)$ http://www.example.org/$1 [L]
http://localhost/universe/networks/o2/o2_logo.gif重新写入http://www.example.org/networks/o2/o2_logo.gif这很棒,但我似乎无法使用
我怎样才能进一步使用这个'更改'%{REQUEST_URI},如$ 1或者其他什么?
Ali*_*air 16
我无法完全使用.htaccess获得此权限,但使用了以下文件:
RewriteEngine On
# Does the file exist in the content folder?
RewriteCond %{REQUEST_URI} !^/content.*
RewriteCond %{DOCUMENT_ROOT}/universe/%{REQUEST_URI} -f
# File Exists
RewriteRule ^ %{DOCUMENT_ROOT}/universe/%{REQUEST_URI} [L]
# If the request is not a file, link or directory then send to index.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L] # Item exists so don't rewrite
# Nothing exists for the request so append a trailing / if needed
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^ %{REQUEST_URI}/ [R=301,L]
RewriteRule ^.*$ index.php [NC,L] # Send off as-is to index.php
Run Code Online (Sandbox Code Playgroud)
然后我进入了我的document_root文件夹并执行了以下操作:
cd /var/www/journal
ln -s journal/public universe
cd /var/www/journal/public
ln -s content/ universe
Run Code Online (Sandbox Code Playgroud)
结合htaccess意味着一切正常.
归档时间: |
|
查看次数: |
74478 次 |
最近记录: |