开发者

PHP Friendly Urls for my script

开发者 https://www.devze.com 2023-04-12 13:20 出处:网络
I have a site which I have converted to use cms made simple. It works perfectly and I have the friendly urls working fine too. My issue is with a little script I wrote myself and how best to integrate

I have a site which I have converted to use cms made simple. It works perfectly and I have the friendly urls working fine too. My issue is with a little script I wrote myself and how best to integrate it. The script is a gallery script, it reads a directory and outputs a formatted gallery in html. I was planning on making it a user defined tag in cms made simple but I hit a small snag.

The gallery script needs to be able to read in two values from the url groupId and showpage.

If I am using freindly urls then the cms and use the tag I hit a snag as the cms tries to find an actual page at "www.mysite.com/gallery/mygroup/2" and then throws a 404.

basically I need

http://www.mysite.com/gallery/photogroup/2

rewritten to

http://www.mysite.com/gallery.php?groupId=photogroup&showpage=2

UPDATE Follwoing Yuri's advice I added his rule to the htaccess. But I have hit another snag. So for instance if we go to 开发者_StackOverflow中文版 http://www.mysite.com/gallery/photogroup/2 then Yuri's rule should take effect. But that path is also a correct physical directory on my site coincidentally. Is there a way to have the rewrite rule take effect instead of bringing me to a white screen browsing the files in the directory or to the forbidden screen if I have indexes turned off which I do.

Below is my htaccess

php_flag magic_quotes_gpc Off

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1

RewriteRule ^gallery/(\w+)/(\d+)$ gallery.php?groupId=$1&showpage=$2 [QSA,L]


So, did you try to write in .htaccess something like this?

RewriteEngine On
RewriteCond ${REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteRule ^gallery/(\w+)/(\d+)$ gallery.php?groupId=$1&showpage=$2 [QSA,L]


sounds like a "module" to me. Maybe this Make your module use clean URLs

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号