|
Home > Archive > Apache Server configuration support > January 2007 > Rewrite URI with query string, somewhat recursive
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Rewrite URI with query string, somewhat recursive
|
|
| therearenoteams 2007-01-07, 7:17 pm |
| Hello list,
I'd like to rewrite /index.php?id=tutorials so that it goes to
/tutorials. Further, /tutorials should then rewrite so that
/index.php?id=tutorials loads 'behind the scenes' (ie, /tutorials is
the canonical URL).
Here are my rules from httpd.conf. Right now, loading
/index.php?id=tutorials redirects to /index.php/ (no idea why). Note
that commenting out the last two rules has no effect. Currently,
rewriting /tutorials to index.php?id=tutorials seems to work; but I
need to go the opposite way too.
Thanks,
Brett
RewriteEngine on
# index.php?id=tutorials should go to /tutorials <-- support old
bookmarks
RewriteCond %{QUERY_STRING} ^id=tutorials$
RewriteRule ^index\.php$ /tutorials? [R]
# tutorials (with no slash) then goes to tutorials/
#RewriteRule ^/tutorials$ /tutorials/ [R]
# tutorials/ (with slash) should load the tutorial index
#RewriteRule ^/tutorials/$ /index.php?id=tutorials [L]
| |
| therearenoteams 2007-01-07, 7:17 pm |
| One other note: there exists a directory /tutorials for this server,
but it's being used to serve included content (it's not accessible
directly). Not sure if this is a problem, since the rewrite to
/tutorials (with index.php?id=tutorials loading in the background)
seems to work fine. But perhaps this directory should be renamed,
moved, or made inaccessible.
Brett
On Jan 7, 3:29 pm, "therearenoteams" <therearenote...@gmail.com> wrote:
> Hello list,
>
> I'd like to rewrite /index.php?id=tutorials so that it goes to
> /tutorials. Further, /tutorials should then rewrite so that
> /index.php?id=tutorials loads 'behind the scenes' (ie, /tutorials is
> the canonical URL).
>
> Here are my rules from httpd.conf. Right now, loading
> /index.php?id=tutorials redirects to /index.php/ (no idea why). Note
> that commenting out the last two rules has no effect. Currently,
> rewriting /tutorials to index.php?id=tutorials seems to work; but I
> need to go the opposite way too.
>
> Thanks,
>
> Brett
>
> RewriteEngine on
>
> # index.php?id=tutorials should go to /tutorials <-- support old
> bookmarks
> RewriteCond %{QUERY_STRING} ^id=tutorials$
> RewriteRule ^index\.php$ /tutorials? [R]
>
> # tutorials (with no slash) then goes to tutorials/
> #RewriteRule ^/tutorials$ /tutorials/ [R]
>
> # tutorials/ (with slash) should load the tutorial index
> #RewriteRule ^/tutorials/$ /index.php?id=tutorials [L]
| |
| therearenoteams 2007-01-08, 7:26 pm |
| The following seems to work. Not much different except the order; a
slash before index.php; and the fact that this is all in httpd.conf,
not an .htaccess
# tutorials (sans slash) so go to tutorials/
RewriteRule ^/tutorials$ /tutorials/ [R]
# tutorials/ (with slash) should load the tutorial index
RewriteRule ^/tutorials/$ /index.php?id=tutorials [L]
# index.php?id=tutorials should go to /tutorials/ <-- support old
bookmarks
RewriteCond %{QUERY_STRING} ^id=tutorials$
RewriteRule ^/index.php$ /tutorials? [R]
On Jan 7, 3:29 pm, "therearenoteams" <therearenote...@gmail.com> wrote:
> Hello list,
>
> I'd like to rewrite /index.php?id=tutorials so that it goes to
> /tutorials. Further, /tutorials should then rewrite so that
> /index.php?id=tutorials loads 'behind the scenes' (ie, /tutorials is
> the canonical URL).
>
> Here are my rules from httpd.conf. Right now, loading
> /index.php?id=tutorials redirects to /index.php/ (no idea why). Note
> that commenting out the last two rules has no effect. Currently,
> rewriting /tutorials to index.php?id=tutorials seems to work; but I
> need to go the opposite way too.
>
> Thanks,
>
> Brett
>
> RewriteEngine on
>
> # index.php?id=tutorials should go to /tutorials <-- support old
> bookmarks
> RewriteCond %{QUERY_STRING} ^id=tutorials$
> RewriteRule ^index\.php$ /tutorials? [R]
>
> # tutorials (with no slash) then goes to tutorials/
> #RewriteRule ^/tutorials$ /tutorials/ [R]
>
> # tutorials/ (with slash) should load the tutorial index
> #RewriteRule ^/tutorials/$ /index.php?id=tutorials [L]
| |
| Harlin 2007-01-09, 1:19 pm |
| Honestly, this is more of a php question than Apache. Try to hit up the
PHP newsgroup instead for this sort of thing.
Harlin Seritt
therearenoteams wrote:
> Hello list,
>
> I'd like to rewrite /index.php?id=tutorials so that it goes to
> /tutorials. Further, /tutorials should then rewrite so that
> /index.php?id=tutorials loads 'behind the scenes' (ie, /tutorials is
> the canonical URL).
>
> Here are my rules from httpd.conf. Right now, loading
> /index.php?id=tutorials redirects to /index.php/ (no idea why). Note
> that commenting out the last two rules has no effect. Currently,
> rewriting /tutorials to index.php?id=tutorials seems to work; but I
> need to go the opposite way too.
>
> Thanks,
>
> Brett
>
> RewriteEngine on
>
> # index.php?id=tutorials should go to /tutorials <-- support old
> bookmarks
> RewriteCond %{QUERY_STRING} ^id=tutorials$
> RewriteRule ^index\.php$ /tutorials? [R]
>
> # tutorials (with no slash) then goes to tutorials/
> #RewriteRule ^/tutorials$ /tutorials/ [R]
>
> # tutorials/ (with slash) should load the tutorial index
> #RewriteRule ^/tutorials/$ /index.php?id=tutorials [L]
|
|
|
|
|