Status
Not open for further replies.

ziycon

New Member
Using this now and im getting an internal 500 error!?!
Code:
RewriteRule ^([^/]*)$ /profile.php?name=$1 [L]
 

CiaranR

Weeno Ltd + Skimlinks.com
Code:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^([^/\.]+)/?$ profile.php?name=$1 [L]

That should do it.
 

ziycon

New Member
Ok, that works fine, but if i got to the www.mysite.com/myname it throws the error page but if i go to www.mysite.com/profile.php?name=myname it works!?!
 

paul

Ninja
500 error is an internal server error. When you have mod rewrite in place, you should still be able to see the URL for the non mod-rewrite'd page , right ? Have you tried this ? Maybe the error is in your script.
 

ziycon

New Member
500 error is an internal server error. When you have mod rewrite in place, you should still be able to see the URL for the non mod-rewrite'd page , right ? Have you tried this ? Maybe the error is in your script.
All i did was change the .htacess line to what i posted in the second post in this thread and it gave me a 500 internal error, once i removed it the site was fine!
 

CiaranR

Weeno Ltd + Skimlinks.com
Can you post your full .htaccess file there should be no problems with the code I said above.
 

davidbehan

New Member
You can add a condition to your rule like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(forum)/.*$
RewriteRule ^([a-z0-9/-]+)$ inner.asp?p=$1 [NC,L]

First line checks that a file doesn't actually exist, second a directory doesn't exist, third the URL doesn't start with forum, and last line (if all conditions above are false) executes the rewrite. I suspect you just need to add the third line to your code in the same format as above.

HTH

Dave
 

CiaranR

Weeno Ltd + Skimlinks.com
3 ways to do it

1. daves way :)
2. add this to the top of you .htaccess
Code:
RewriteRule ^/?(forum)/$ forum/index.php [L]
3. add a .htaccess file to the forum folder with "RewriteEngine off"

Another helpful rule is

Code:
#
# ONLY FOR TESTING REWRITE RULES!!!!!
#
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 5
NEVER use this rule on a live site only use it for testing, the log files would be HUGE
 

davidbehan

New Member
3 ways to do it

1. daves way :)
2. add this to the top of you .htaccess
Code:
RewriteRule ^/?(forum)/$ forum/index.php [L]
3. add a .htaccess file to the forum folder with "RewriteEngine off"

Another helpful rule is

Code:
#
# ONLY FOR TESTING REWRITE RULES!!!!!
#
RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 5
NEVER use this rule on a live site only use it for testing, the log files would be HUGE

Not promoting my own here but 2 would redirect everything from mysite.com/forum/ to mysite.com/forum/index.php and ignore the rest of the rules. Although it would work, personally I'd prefer not to see index.php. With 3, you won't be able to use htaccess in that folder then and I presume that you will want that if it's set up like this forum for example (see url above). If I'm wrong with that analysis of that rewrite code, sorry - I've only been writing them for a couple of months now.

Good to have a bit of lateral thinking of a solution though.

Thanks for the log file code - that would have been handy recently when I was debuging what the hell htaccess was doing! :D

Rgds, Dave
 

ziycon

New Member
That worked a treat, thanks lads. One another note while i have you here, any suggestions why mod_rewrite wont work at home on my test machine?
 

CiaranR

Weeno Ltd + Skimlinks.com
Ziycon if you are running apache on xp there should not be a problem make sure mod rewrite is enabled in apache. I test using xampp on my xp machine and have no problem testing mod rewrite.

David my first one (no.2) should work as expected and leave the url as mysite.com/forum/ the same as with any other rule it doesn't add index.php, not sure why you thought it would.

The 3rd does have that obvious disadvantage but without knowing his forum setup it may the easiest way so its good to have it as an option, lateral thinking as you say.

Saying that I think your solution is the best one and would be the recommended one by me too.
 
Status
Not open for further replies.
Top