how can i show only the index.php and ignore any other calls to other php files, so if i were to go to somefile.php, the page would stay at index.php all the time, however if i were to go to index.php?get=somefile it would then allow you to execute that.
so in short i only want the index.php to be the main caller and executor of everything and to ignore any calls to any other php files that is not index.php.
i have this in my .htaccess.
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
it does everything i'm asking for but it dosen't let you call any php file using get in index.php like index.php?get=somefile
where is it going wrong and how do i correct it?
You are not rewriting the get parameter. Try this:
RewriteRule ^(.*)$ index.php?get=$1
Right Now your htaccess code is creating a url of:
index.php/somefile.php
Add
RewriteCond %{REQUEST_URI} !^index.php.*
From here you can do two things
1) Change RewriteRule ^(.*)$ index.php/$1 to:
RewriteRule ^(.*)$ index.php?get=$1
2) Add another RewriteRule:
RewriteRule ^index.php/(.*)$ index.php?get=$1 [L]
Depending on your server setup you may need to change index.php?get=$1 to one of the following
./index.php?get=$1
http://yourdomain.com/index.php?get=$1
Then on your index.php page you would include the page passed by the $_GET['get'] variable.
Here's your final rule, tell me if it works:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/?get=$1 [QSA,L]
http://wiki.apache.org/httpd/RewriteFlags/QSA
RewriteRule ^(.*)$ index.php/$1 [QSA]
So if you went to site.com/?get=asdf
, you could access that via $_GET['get']
in your index.php
file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.