使用PHP.htaccess重写URL

使用PHP.htaccess重写URL,php,.htaccess,mod-rewrite,web,Php,.htaccess,Mod Rewrite,Web,所以基本上我在我的php网站上得到了这个URL,看起来像这样,我没有访问httpd.conf,或者我不知道如何使用它,我只想使用它。htaccess: 我该如何将该URL转换为 我已经试过了。htaccess 在上重写引擎 重写规则^/full/([0-9]+)$/full.php?id=$1 请提供完整的工作代码,以便在.htaccess中使用。请尝试以下操作: Options -MultiViews RewriteEngine on RewriteBase / RewriteCond

所以基本上我在我的php网站上得到了这个URL,看起来像这样,我没有访问httpd.conf,或者我不知道如何使用它,我只想使用它。htaccess:

我该如何将该URL转换为

我已经试过了。htaccess


上重写引擎 重写规则^/full/([0-9]+)$/full.php?id=$1

请提供完整的工作代码,以便在.htaccess中使用。请尝试以下操作:

Options -MultiViews

RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_END} !^1$
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteRule ^([A-Za-z_-]+)\.php$ $1/%1? [R=301,L]

RewriteCond %{ENV:REDIRECT_END} !^1$
RewriteRule ^([A-Za-z_-]+)\.php$ $1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z_-]+)/(.+)$ $1.php?id=$2 [E=END:1,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z_-]+)$ $1.php [E=END:1,L]

这将重写/foo/bar/to/foo.php?id=bar

删除htaccess中的内容,并仅放置我的代码。此外,“不工作”也不清楚。发生了什么?请提供更多细节!什么不起作用?您尝试访问哪个url?结果是什么(404错误…?)好的,这是url(),重写不起作用,我的代码确实起作用了。。。请参阅:您还必须在页面的
html标记之后添加
,以修复css、图像和js众所周知的问题。如果存在smthng mod rewrite enabled/disabled问题,请参阅phpinfo()页面?
RewriteRule ^(.*)/(.*)$ /$1.php?id=$2 [L]