blu*_*dtt 19 .htaccess mod-rewrite
我想重写http://example.com/articles.html#first-article与http://example.com/articles/first-article
有可能重写吗?
我尝试使用以下但不适合我:
RewriteRule ^articles/(.+)$ /articles\.html\#$1
Run Code Online (Sandbox Code Playgroud)
Fel*_*a A 37
该#可与NE标志替换URL添加.校验:
这个Apache链接具体描述了如何redirect anchors.
所以,你可以试试这个:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !articles\.html [NC]
RewriteCond %{REQUEST_URI} ^/articles/([^/]+)/? [NC]
RewriteRule .* /articles.html#%1 [R,NE,L]
Run Code Online (Sandbox Code Playgroud)
重定向
http://example.com/articles/parameter
至
http://example.com/articles.html#parameter
articles假设字符串是固定的,而parameter假设它是可变的.
Fab*_*ler 21
不,这是不可能的.该URL片段(一切从#上)甚至没有被发送到服务器.
也许您想要考虑基于JavaScript的解决方案,其中实际内容将通过AJAX加载,具体取决于片段.您将在此处找到有关此方法的一些有用信息:Facebook中的shebang/hashbang(#!)和新的Twitter URL是什么?
| 归档时间: |
|
| 查看次数: |
25501 次 |
| 最近记录: |