Generating SE friendly URL .htaccess mod rewrite

瘦欲@ 提交于 2019-12-25 05:36:50

问题


I've a URL which get file name through get method and display it on the page.

tvchaska.info/i/ 

this is the page and when u click any image it will go to say

http://tvchaska.info/i/output.php?i=http://brothertattoo.co.uk/wp-content/uploads/2011/09/Sexy-Girl-Tattoo.jpg 

I want my this URL to be rewritten as tvchaska.info/i/Sexy-Girl-Tattoo.html

I tried following rule but it is not working

    RewriteEngine On
    RewriteRule ^([^/]*)\.html$ /output.php?i=$1 [L]

Can any one plz help me to attain this plz?


回答1:


I've seen you page, I'll give you the answer only if I can meet 3 girls of your page IRL! Just kidding.

Here's the solution:

-1: all your link don't have to be like:

/i/output.php?i=http://1.bp.blogspot.com/_R2Wo1mDtuko/TGzOFQEhpoI/AAAAAAAACAA/Na-WQ1xe7dY/s1600/sexy.jpg

but something like:

/i/1.bp.blogspot.com/_R2Wo1mDtuko/TGzOFQEhpoI/AAAAAAAACAA/Na-WQ1xe7dY/s1600/sexy.jpg

-2: once you've modified your site, apply those rules:

RewriteEngine On
RewriteRule ^/i/(.*)+ /i/output.php?i=http://$1

This will do the job.

Olivier



来源:https://stackoverflow.com/questions/8178690/generating-se-friendly-url-htaccess-mod-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!