Php 如何像facebook那样缩短我的url到用户个人资料页面

Php 如何像facebook那样缩短我的url到用户个人资料页面,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我正在尝试缩短我的网站url的一个新添加的页面事件,如 mysite.com/asoebi/myevent而不是mysite.com/asoebi/index.php?event=myevent 但每次我试图更改.htaccess文件时,它都会给出一个错误 这是.htaccess代码 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %

我正在尝试缩短我的网站url的一个新添加的页面事件,如

mysite.com/asoebi/myevent
而不是
mysite.com/asoebi/index.php?event=myevent

但每次我试图更改.htaccess文件时,它都会给出一个错误

这是.htaccess代码

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^index/(\w+)$ ./index.php?event=$1

</IfModule>

重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
重写规则^index/(\w+)$./index.php?事件=$1

您必须在apache中启用mod_rewrite才能工作

将此文件放入
.htaccess
文件夹中的
/public\u html/asoebi/
文件中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /asoebi/
RewriteRule ^(.*)$ index.php?event=$1 [L]

</IfModule>

重新启动发动机
重写基/asoebi/
重写规则^(.*)$index.php?事件=$1[L]

同时从您在上面发布的主htaccess文件中删除最后一条重写规则

这是WordPress网站吗?您的新规则永远不会执行,因为上一个块(看起来像WordPress规则)匹配所有不存在的文件/文件夹。所以你需要把你的规则放在it@LeonardChallis不,不,现在显示的页面与第页上的页面相同。当有人进入时,我想显示页面。请告诉htaccess文件所在的目录。该目录位于主网站的/public_html目录中,也位于/public_html/asoebi目录中。该子网站是我想重写urli的子网站。我和你说的一样,但在将htaccess文件放入/public_html/asoebi/文件夹之后网站工作不正常,即使css未加载,也会从主htaccess文件中删除最后一个重写规则,但每当我编写faari.ng/asoebi/myevent时,它都会显示faari.ng页面