创建一个漂亮的URL(Creating a Pretty URL)
它几乎类似于如何创建漂亮的网址,但它似乎并不适合我。
这是我的网址:
http://localhost/pr/ajax/ajax_load.php?task=get_blob&blid=199我如何将其转换为:
http://localhost/pr/ajax/get_blob/199这是我的.htaccess :
RewriteEngine On RewriteBase /pr/ajax/ RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+pr/ajax/ajax_load\.php\?task=([&\s]+)&blid=([0-9]+) [NC] RewriteRule ^/%1/%2? [R=301,L,NE] RewriteCond %{ENV:REDIRECT_STATUS} !200 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^([^/]+)/([^/]+)/?$ /pr/ajax/ajax_load.php?task=$1&blid=$2 [L,NC,QSA,NE] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(js|css|jpeg|gif|png|pdf)$ /pr/ajax/%{REQUEST_URI} [NC,L,R=302]你应该把.htaccess放在哪里? 我的意思是,你把它放在哪里很重要? 我的根源是pr 。
It almost is similar to how to create pretty urls but, it does not seem to work for me.
Here is my url:
http://localhost/pr/ajax/ajax_load.php?task=get_blob&blid=199How do I convert it to:
http://localhost/pr/ajax/get_blob/199Here is my .htaccess:
RewriteEngine On RewriteBase /pr/ajax/ RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+pr/ajax/ajax_load\.php\?task=([&\s]+)&blid=([0-9]+) [NC] RewriteRule ^/%1/%2? [R=301,L,NE] RewriteCond %{ENV:REDIRECT_STATUS} !200 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^([^/]+)/([^/]+)/?$ /pr/ajax/ajax_load.php?task=$1&blid=$2 [L,NC,QSA,NE] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(js|css|jpeg|gif|png|pdf)$ /pr/ajax/%{REQUEST_URI} [NC,L,R=302]Where should the .htaccess be placed? I mean, does it matter where you put it at? My root is at pr.
最满意答案
试试这个:
RewriteEngine On RewriteRule ^/pr/ajax/(.*)/(.*)$ /pr/ajax/ajax_load.php?task=$1&blid=$2 [NC,L]是的,你把htaccess文件放在哪里都很重要。 您将文件放在要修改/操作其路径的文件的目录中。
Try this:
RewriteEngine On RewriteRule ^/pr/ajax/(.*)/(.*)$ /pr/ajax/ajax_load.php?task=$1&blid=$2 [NC,L]And yes, it does matter where you put the htaccess file. You put the file in the directory of the file whose path you want to modify/manipulate.
更多推荐
发布评论