I'm trying to build a construct for redirecting or "beautifying" URL.
I would like to achieve following result:
My current approach is
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA]
I tried a lot, but either it doesn't work or it will end in an unstyled page. Any suggestions?
Use absolute links in your pages.
If you use any graphics or links in your pages, don't use "relative links". Instead, make all your links "absolute links" that start with http://www.example.com/...
.
Or a root-relative link, beginning the href value with /
.
In your case: http://www.example.com/css/Stylesheet.css
or /css/Stylesheet.css
;
You can also add in the html <head>
: <base href="/">
If you only use parameters at the root of the site, you can use:
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]
# with one parameter
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)/([^/]+)/?$ $1.php?hash=$2 [L,NE,QSA]
# with two parameters
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?hash=$2&status=$3 [L,NE,QSA]
Thanks! Shame on me. That fixes the styling problem. But the GET parameters are still missing … any idea?
I added it in my answer
Thanks so much! You nailed it