apache - PHP: htacess default variable -


I want to set a default variable for a query that comes to the end of the url

The .htaccess file redirects URL to:

  http://www.server.com/folder/subfolder/index.php?page= "some page-names"  

Display URL

  http://www.server.com/folder/some-page-name  


If the page name is not set, then in this form:

  http://www.server.com/folder/  

The default "index" will be the php function header ("s" Location: url ") , but it will display the" Index "portion at that time if the URL ... which I do not want.



Htacess content

  option-index < IfModule mod_rewrite.c & gt; RewriteEngine # RewriteCond% {REQUEST_URI}! ^ (/ Index.php | / img | / js | / css | / robot \ .txt | / favicon \ .ico) Revertbase / folder / rewrite rule ^ index \ .php $ - [L] Revoked% {REQUEST_FILENAME}! -f rewrite code% {REQUEST_FILENAME}! -d Recovery code% {REQUEST_URI}! ^. * .. CSS $ $ [Nc] rewritable ^ (. *) $ Subfolder / index PHP /? Page = $ 1 [L] & lt; / IfModule & gt; & Lt; IfModule mod_rewrite.c & gt; ErrorDocument 404 /error.html Error Document 403 /error.html & lt; / IfModule & gt;  

You do not need to redirect to index.php You can use:

  header ('location: / folder / front page');  

If you want to show your index page, then you can use the following in your PHP script:

  $ request_page = filter_input (INPUT_GET), 'PageID'); $ Permission_page = array ('some-page', 'some-page-name'); If ($ request_page == '') {// your index page is "PageID not set or not empty" asif (in_array ($ request_page, $ allow_pages)) {// display $ request_page} else {// display a 404 Not Found Error}  

Comments