This is mainly an htaccess problem I guess but it has to do with PHP for now!
So basically I want prettier URLs but I want to keep index.php in the URL! So normally you would have domain.com/home or domain.com/about BUT I want it like domain.com/index.php/home.
I'm getting info from a database with the old fashioned $_GET, mine is $_GET["p"].
So my current .htaccess file looks like this,
[syntax=text]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ index.php?p=$1 [NC]
[/syntax]
But this doesn't keep index.php in the URL so if you guys have any idea on how to achieve this then I would greatly appreciate you telling me
.htaccess BUT keep index.php
Re: .htaccess BUT keep index.php
You could jutt include the index.php part in the match line ?
[syntax=text]RewriteRule ^index.php/(.*)$ index.php?p=$1 [NC][/syntax]
Something like that ?
[syntax=text]RewriteRule ^index.php/(.*)$ index.php?p=$1 [NC][/syntax]
Something like that ?
Re: .htaccess BUT keep index.php
I tried that at first but it didn't work so I removed this,
[syntax=text]RewriteRule .* - [L][/syntax]
line because it looked suspicious and now it's working.
Problem is, it breaks the folder structure so it doesn't link the CSS file :/
[syntax=text]RewriteRule .* - [L][/syntax]
line because it looked suspicious and now it's working.
Problem is, it breaks the folder structure so it doesn't link the CSS file :/
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: .htaccess BUT keep index.php
Do direct links to CSS instead of relative?
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Re: .htaccess BUT keep index.php
bowersbros wrote:Do direct links to CSS instead of relative?
Then I have to somehow force users into doing that :/ Which is tricky.
And images would then also have to be directly linked outside of the css :/
Re: .htaccess BUT keep index.php
It should not break the css links if you use a / at the start of your href. for example, imaging you are at http://something.com/index.php/page and you have
[syntax=xhtml]<link rel="stylesheet" type="text/css" href="ext/css/main.css" />[/syntax]
That will try to request http://something.com/index.php/page/ext/css/main.css which may be wrong.
but if you use
[syntax=xhtml]<link rel="stylesheet" type="text/css" href="/ext/css/main.css" />[/syntax]
it will try to request http://something.com/ext/css/main.css which is probably right
/ means root.
[syntax=xhtml]<link rel="stylesheet" type="text/css" href="ext/css/main.css" />[/syntax]
That will try to request http://something.com/index.php/page/ext/css/main.css which may be wrong.
but if you use
[syntax=xhtml]<link rel="stylesheet" type="text/css" href="/ext/css/main.css" />[/syntax]
it will try to request http://something.com/ext/css/main.css which is probably right
/ means root.