PDA

View Full Version : .htaccess help?



Jme
27-08-2008, 01:37 AM
Hey,

I'm trying to use RewriteEngine to alter the url's on my site but it keeps either doing something I don't want or giving an internal server error.



RewriteRule ^newsite/(.*)$ newsite/?p=$1 [L]


that gives an internal server error.
I want it to be like site.com/newsite/pagename

I tried


RewriteRule ^newsite/(.*)/$ newsite/?p=$1 [L]

That worked kind of but you HAD to have the / after the page name or else it wouldn't work and I don't want to have the /.

It'd be cool if anyone could help.

Cheers,
Jamie

Invent
27-08-2008, 02:04 AM
I think this may be the issue (not v. good with htaccess), you're telling the server to rewrite the url /newsite/<anything> to /newsite/?p=<anything>, which if you think about it logically will cause a loop of rewrites.

Try something like:



RewriteRule ^newsite2/(.*)$ newsite/index.php?p=$1 [L]

Jme
27-08-2008, 02:18 AM
Just returns a 404 error. Cheers anyway :)
Anyone else able to help?

Invent
27-08-2008, 02:56 AM
That's strange as it worked perfectly on my localhost :P

Jme
27-08-2008, 03:01 AM
That's strange as it worked perfectly on my localhost :P



RewriteRule ^newsite/(.*)$ newsite/index.php?p=$1 [L]


includes:


newsite/index.php.php


It's treating index.php as part of the $1 variable.
When I take index.php out I get the internal server error, LOL

The only way to solve this is to do:


RewriteRule ^newsite/page/(.*)$ newsite/index.php?p=$1 [L]


so it'd be like

site.com/newsite/page/pagename

But I don't want that either, haha.

It's seriously rattling my brain :(

Maybe i'm just being too fussy.

Invent
27-08-2008, 03:34 AM
lol, I can't think properly at the moment (probably due to the fact its half four in the morning, lol), so I'll post a working method tomorrow for 'ya ;)

Jme
27-08-2008, 04:27 AM
Thanks, Simon :D
I'll keep on trying, doubt i'll get anywhere tho hahaha.

Calon
27-08-2008, 07:44 AM
RewriteEngine On
RewriteRule ^([^/]*)$ /newsite/index.php?p=$1 [L]

But, that would be

http://www.site.com/pagename

which I suppose is better? :)

Jme
27-08-2008, 01:14 PM
Yeah, but the site's in a folder on the server called newsite :(

Want to hide these adverts? Register an account for free!