Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
help with a rewrite!
Hi All,
is there any way to rewrite this url:
http://sub.domain.com/?id=100&something=200
to:
http://sub.domain.com/photo/100/200
Is that possible?
Although, idealy, I would rather have it like this:
http://sub.domain.com/photo/article-title/200
but I think that requires to much work.
Any thoughts?
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline
Re: help with a rewrite!
yes, your first example is doable. How? you’ll have to get someone else to show you the code. I do know it can be done, since I had someone write something similar for me once.
the second option could be done if you wanted to use PHP to handle the redirects (instead of the .htaccess file). You would need to pull the article-title from the db, then redirect to that page.
Eric
Offline
Re: help with a rewrite!
Well then, I guess I’m looking for a mod-rewrite master to help me out a little!
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline
Re: help with a rewrite!
I found a lot of the mod rewrite sites use what your looking at as an example. So you might be able to find some samples via Google and then make them fit your particulars.
Eric
Offline
Re: help with a rewrite!
Thanks! I wouldn’t have come to the forums if I didn’t already try that. ;)
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline
Re: help with a rewrite!
http://sub.domain.com/?id=100&something=200
to:
http://sub.domain.com/photo/100/200
No guarantuee, untested. Idally test this locally first. ;)
RewriteCond %{QUERY_STRING} id=([0-9]+).*something=([0-9]+)
RewriteRule .* /photo/%1/%2? [R=301,L]
(note: The question-mark at the end is necessary to prevent an endless loop: it “empties” the query string).
Offline
Re: help with a rewrite!
Nah that didn’t seem to work. Although something interesting to note is that…
sub.domain.com/photo/?id=100&imagenum=200 now redirects to /photo/100/200
Here’s the whole .htaccess file if it helps…
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^diana.bertelsen.ca$ [NC]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) – [PT,L]
RewriteRule ^(.*) /index.php
RewriteCond %{QUERY_STRING} id=([0-9]+).*imagenum=([0-9]+)
RewriteRule .* /photo/%1/%2? [R=301,L]
</IfModule>
#php_value register_globals 0
Last edited by 1beb (2005-12-02 23:42:14)
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline
Re: help with a rewrite!
Gah, all that I can get to happen is “404 not found!”
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline
Re: help with a rewrite!
Is it generating the URLs correctly, and something else is breaking, or is it generating the wrong URL?
Eric
Offline
Re: help with a rewrite!
It generates the correct URL, but txp says “no, thank you.”
Proud Canadian. Toronto Locksmith , Actualize Consulting
Offline
Pages: 1