.htaccess w/ mod_rewrite Issues

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

.htaccess w/ mod_rewrite Issues

Post by John Cartwright »

Hey guys, heres my problem

Code: Select all

Options +FollowSymLinks 
RewriteEngine On
RewriteBase /

RewriteRule ^([A-Za-z]+).rtr$ index.php?page=$1
Very simple rule, I've been working with mod rewrite for some time but I am baffled. My current url is looking like

http://localhost/projects/runtings/artists.rtr

.htaccess is located in /runtings/

Of course changing artists to something else, anything else, even artists itself, results in a blank page. My index.php is not even loaded, so I do not know what do to from here.

Thank ye.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Seems I had to add the futh path to the index, as it was grabbing the index.php in my root directory, not the current directory :?

Code: Select all

RewriteRule ^([A-Za-z]+)$ http://localhost/projects/runtings/index.php?page=$1
Previously when using mod_rewrite I've never had to do this, so can anyone offer insight, and possibly a way to avoid having to write the futh path?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Probably due to the base directory being set as the document root of the webserver/virtual host

i.e...

Code: Select all

RewriteBase /
.. means that any path specified will be from the ducoment root directory of the webserver/virtual host.

Your orginal rule would probably work fine with

Code: Select all

RewriteBase /projects/runtings/
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Thanks for the advice thus far. I'm now having problems with my links, for example: a link <a href="home">Home</a> would with the url being
http://localhost/projects/runtings/artists/ would conver the link into <a href="http://localhost/projects/runtings/arti ... e">Home</a> instead of <a href="http://localhost/projects/runtings/home">Home</a>

my htaccess looks like

Code: Select all

Options +FollowSymLinks 
RewriteEngine On
RewriteBase /projects/runtings/


RewriteRule ^(article)/([0-9]+)$ index.php?page=$1&view=$2 [L]
Thanks :0
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Which version of Apache are you running?

And where exactly is this .htaccess file within your directory structure?

This is a different .htaccess file from the original posted?
Post Reply