Mod_rewrite

software development

#1

I was just curious if anyone else has ever tried doing mod_rewrite on their website. I can’t get it to work, and frankly right now I’m upset with DH’s support. It’s taking a long time for replies. I’ve set up a webpage via a tut about mod_rewrite and http://www.munx.net/test/alice.html it is supposed to say “This is bob’s page”, but it doesn’t (which it http://www.munx.net/test/bob.html).

Anyone have any ideas? Thanks,
–pyius


#2

You probably have a mistake in your rewrite rules. I use mod_rewrite extensively on my site and it works fine.

Learn to love the mod_rewrite documentation. It may take a little time and patience but you’ll get it eventually.

You may find it helpful to post your rules here. Many eyes and all that.


If you want useful replies, ask smart questions.


#3

Yeah, kchrist is probably right about that. I also make extensive use of mod_rewrite, and everything works just fine; however, I’m hopeless at writing it myself. I always need other people to help me with it. I find the documentation completely bewildering!


Simon Jessey
Keystone Websites | si-blog


#4

Thanks for helping out. DH support is really annoying me right now.

Right now, I’ve got my .htaaccess file set to:
I’ve got the .htaaccess file in …/munx.net/test/.htaaccess

RewriteEngine on
RewriteRule ^alice.html$ bob.html

I’ve also got an alice.html and bob.html file in the same directory. From what I read of the tutorial, it should display “This is bob’s page” which is what bob.html is.

http://www.munx.net/test/alice.html
http://www.munx.net/test/bob.html

I’ve also read that mod_rewrite should show up in loaded module in php_info (http://www.munx.net/phpinfo/), but I can’t find mod_rewrite within it.

Any help would be greatly appreciated. I’m really trying to redo my website within the next couple days to monitor bandwidth for pictures.

Thanks,
–pyius


#5

It won’t appear because you have your version of PHP set to run in CGI mode. Compare your phpinfo file to my own. You will see the mod_rewrite module in the apache section.


Simon Jessey
Keystone Websites | si-blog


#6

Changed my PHP to not run as CGI, however, didn’t change much. It now displays mod_rewrite under phpinfo, but it didn’t change anything for my mod_rewrite.

Can you give me any example mod_rewrite that I can test?

Thanks,
Dustin


#7

Here’s a basic redirect, using mod_rewrite, that will make your server transparently redirect from old.html to the new.html page.:

RewriteEngine on RewriteRule ^old\.html$ new.htmlHere’s the same rule, but modified to force a new HTTP request:

RewriteEngine on RewriteRule ^old\.html$ new.html [R]---------------
Simon Jessey
Keystone Websites | si-blog


#8

Nope…didn’t change a thing.

http://www.munx.net/test/old.html

That should still say “Bob” (which is new.html), but it still doesn’t :(.

Have any ideas?

Thanks,
–pyius


#9

It’s .htaccess - you’ve got too many a’s. Check the filename on the server.

:cool: Perl / MySQL / HTML+CSS


#10

Perfect!! :smiley:

That wasn’t so hard, thanks for actually helping.

The only problem I have now, is that when it looks for “new.html”, it tries to go to:
http://www.munx.net/home/pyius/munx.net/test/new.html

instead of just http://www.munx.net/test/new.html

Any idea why?

Thanks again very much!,
–pyius


#11

The only problem I have now, is that when it looks for “new.html”, it tries to go to:
http://www.munx.net/home/pyius/munx.net/test/new.html

You’re using the filesystem path (eg, /home/username/domain/etc) instead of the URI path. The path in your rewrite rules should be relative to the web site’s document root. In your case this is /home/pyius/munx.net/. Leave this part out.


If you want useful replies, ask smart questions.


#12

Thanks again.

I got everything up and working now ^_^.

You all are much more helpful than DH support :P. Now I can start revamping my site…I’ve only got about 2 days left.

Thanks again,
–pyius