仅当我有 /blog/ URI 时如何重定向到子目录
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
# we redirect to blog if requested
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule .* /blog/index.php [L]
</IfModule>
你好,我还不太擅长 htaccess,只是需要快速帮助。 上面的文件将所有内容重定向到“blog”子目录。 我如何确保只有 url/blog/ 被重定向,而其余所有内容都按其应有的方式进行? 谢谢
我想要的是:
非域/博客的网址正常运行并指向“web/index.php”
仅“domain/blog”指向“web/blog/index.php”
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
# we redirect to blog if requested
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule .* /blog/index.php [L]
</IfModule>
Hi there, I am not that good with a htaccess yet, just need a quick help.
the file above redirects everything to "blog" subdirectory.
How can I make sure that only url/blog/ gets redirected and all the rest does as it should?
thanks
What I want is:
url that is not domain/blog to act as normal and point to "web/index.php"
Only the "domain/blog" to point as "web/blog/index.php"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这可能非常适合您的需求。除非
web
和blog
都使用良好的前端控制器模型,只需要让服务器重定向到它们。Right, this is probably very simplified for your needs. Unless both the
web
andblog
use good Front Controller models that just need to have the server redirect to them.