Shinyshell Community Forums > Coding > Rewriting URLs. |
||||||
Sign Up | Member List | New Posts | Help |
[1]
August 15 02009, 19:33 GMT | ||||
Sir Aaron (~Wake Me Up Inside~) Location: USA Post count: 10 |
Hey, I haven't really posted here in a while.. I never stopped looking at the forum though.
Anyway, recently I've switched my site to a PHP template engine, and my URLs are all now ?page=page. I was wondering, how I might rewrite the URL's to have no extension. I tried a few times, modifying other ones I saw, but they all don't work. Any ideas? Thanks! |
August 17 02009, 08:59 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
To get rid of the extension, I use:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([A-Za-z0-9_-]+)?$ $1.php [L,QSA] Let me know how it goes. |
August 18 02009, 03:22 GMT | ||||
Sir Aaron (~Wake Me Up Inside~) Location: USA Post count: 10 |
Oh, sorry, I worded my post wrong. I meant, I would like to rewrite the /index.php?page=about to /about.
Anyway, though I used to use that code before, and it worked, right now isn't working at all.. |
August 24 02009, 19:58 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
Oh dear, okay... I'm sorry for making you wait a week, for some reason I thought I'd resolved this... :(
This should do what you're looking for: RewriteEngine On # a url that doesn't identify a file or # directory that exists will be rewritten RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*?)/? index.php?page=$1 |
August 25 02009, 21:50 GMT | ||||
Sir Aaron (~Wake Me Up Inside~) Location: USA Post count: 10 |
Haha, it's okay.
And oh, that doesn't work either...>_>. I think something is wrong with my site..nothing's really working. Is there a way to see if Apache/ .htaccess is working alright? |
August 28 02009, 05:11 GMT | ||||
SpaceMan Member Location: Earth Post count: 32 |
The server will react with 500 Internal Server Error when the .htaccess has errors, so intentionally write a wrong .htaccess and see what happens.
Maybe you can't do www.example.com/PageName, but you can do www.example.com/p/PageName RewriteEngine On RewriteRule ^p\/([^\/]+)$ index.php?page=$1 |
August 28 02009, 13:54 GMT | ||||
Sir Aaron (~Wake Me Up Inside~) Location: USA Post count: 10 |
And that doesn't work either. It turns up a 404 error.
|
[1]
Forum Information |
||||||||||
|