更改url.htaccess.php
我有一个页面名更改url.htaccess.php,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个页面名page.php,我的url是localhost/mysite/page.php,现在如何使用.htaccess文件将url更改为localhost/mysite/somethinghere1/somethinghere2/page.php 它尝试使用下面的代码,但没有成功 <IfModule mod_rewrite.c> # Enable Rewriting RewriteEngine On # Rewrite user URLs # Input: us
page.php
,我的url是localhost/mysite/page.php
,现在如何使用.htaccess
文件将url更改为localhost/mysite/somethinghere1/somethinghere2/page.php
它尝试使用下面的代码,但没有成功
<IfModule mod_rewrite.c>
# Enable Rewriting
RewriteEngine On
# Rewrite user URLs
# Input: user/NAME/
# Output: user.php?id=NAME
RewriteRule ^somethinghere1/somethinghere2/.php? page.php
</IfModule>
#启用重写
重新启动发动机
#重写用户URL
#输入:用户/姓名/
#输出:user.php?id=NAME
重写规则^somethinghere1/somethinghere2/.php?page.php
我怎样才能做到这一点。这个怎么样:
RewriteRule ^somethinghere1/somethinghere2/([^/\.]+).php/?$ page.php
那么这个呢:
RewriteRule ^somethinghere1/somethinghere2/([^/\.]+).php/?$ page.php
像这样使用它:
RewriteRule ^(mysite/)somethinghere1/somethinghere2/(.*\.php)/?$ $1$2 [L,NC]
还要确保文档根目录中的.htaccess文件中有此文件。如下所示:
RewriteRule ^(mysite/)somethinghere1/somethinghere2/(.*\.php)/?$ $1$2 [L,NC]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/page.php /page.php?first=$1&second=$2 [NC]
还要确保该文件位于文档根目录的.htaccess文件中
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/page.php /page.php?first=$1&second=$2 [NC]
这是基本代码,您可以使用它来满足您的需要,如以下编辑:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+) /$3.php?first=$1&second=$2 [NC]
那么x/y/z应该是z.php?first=x&second=y
这是基本代码,您可以使用它来满足您的需要,如以下编辑:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+) /$3.php?first=$1&second=$2 [NC]
那么x/y/z应该是z.php?first=x&second=y我已经编辑了这个问题,我也检查了你的解决方案,但是没有成功。我得到了这个,但是我需要将
localhost/mysite/page.php
url更改为localhost/mysite/something1/something2/page.php
这就是我要找的。@Rafee:所以你需要将localhost/mysite/page.php重定向到localhost/mysite/something1/something2/page.php,你可以使用.htaccess来完成。我已经编辑了这个问题,我也检查了你的解决方案,但它不起作用。我得到了这个,但是我需要将localhost/mysite/page.php
url更改为localhost/mysite/something1/something2/page.php
,这就是我要找的。@Rafee:所以你需要将localhost/mysite/page.php重定向到localhost/mysite/something1/something2/page.php,你可以使用.htaccess来实现。