关于模块重写的语法
我对模块重写的语法有一些疑问。我想知道如何编写不包含/包含某些文件的规则?
例如:
目录结构:
- /
- /home.php
- /profile.php
- /pages
- /pages/index.php
- /pages/.htaccess
关于 /pages/index.php 内容:
<?php include_once "../home.php" ?>
关于 /home。 php 内容:
<a href="profile.php">Profile</a>
所以:我想在页面目录中编写一个 .htaccess,并使超链接(profile.php)在用户单击个人资料文本时正确。
RewriteEngine On
RewriteBase /pages2
RewriteRule ^(images|css|js|plugins)/(.*) http://localhost/$1/$2
# if end with .php ext and file name not index.php then redirect to parent directory
RewriteCond %{SCRIPT_FILENAME} .php$
RewriteCond %{SCRIPT_FILENAME} !index.php$ ## not work ?
RewriteRule ^(.*) http://localhost/$1
在这种情况下,我无法更改根路径文件内容。
i have some question about the syntax of module rewrite. i would like to know how to write a rule to not include/contain some file?
For example:
Directories structure:
- /
- /home.php
- /profile.php
- /pages
- /pages/index.php
- /pages/.htaccess
About the /pages/index.php content:
<?php include_once "../home.php" ?>
About the /home.php content:
<a href="profile.php">Profile</a>
So: i would like to write a .htaccess in the pages directory, and make the hyperlink (profile.php) is correct when user click on Profile text.
RewriteEngine On
RewriteBase /pages2
RewriteRule ^(images|css|js|plugins)/(.*) http://localhost/$1/$2
# if end with .php ext and file name not index.php then redirect to parent directory
RewriteCond %{SCRIPT_FILENAME} .php$
RewriteCond %{SCRIPT_FILENAME} !index.php$ ## not work ?
RewriteRule ^(.*) http://localhost/$1
In this case , i can not change the root path file content.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哈哈,你不需要任何规则:) 就去做吧
lol you don't need any rules :) just make it