-1

I'm trying in the .htaccess-file to replace index.php?p=sites with a name, for example instead of

www.sitename.com/index.php?p=help -> www.sitename.com/help/

I still have no solution.

Rizier123
  • 58,877
  • 16
  • 101
  • 156
Apromer
  • 59
  • 2
  • 8
  • 1
    possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Stubborn Nov 29 '14 at 18:26

1 Answers1

0

Your .htaccess should be like this

<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?p=$1 [QSA,L]

</IfModule>

And PHP will get this link www.sitename.com/help/ as www.sitename.com/index.php?p=help So you can get p as $_GET['p']

Oleg
  • 655
  • 4
  • 10
  • Hey, thank you very much. I have insert the code into the .htaccess-file but the **www.sitename.com/index.php?p=help** site can't be called with **www.sitename.com/help/** - I don't understand what you are meaning with the `$_GET['p']`, I think this is why the link (www.sitename.com/help/) isn't working. :/ – Apromer Nov 29 '14 at 18:59
  • Rewright works 100%. But You need to be sure then your .htaccess file works well. Try to put in top of .htaccess file --> deny from all. This should block all access to website – Oleg Nov 29 '14 at 19:04
  • The file works well. But it isn't working.. has it something to do with `$_GET['p']` as you already wrote above? I didn't unterstand that.. – Apromer Nov 29 '14 at 19:07
  • No, you can ignore $_GET['p'] if you just need to rewright URL. I describe how to get this var in PHP if you will be needed. But seems you don't need it now, and you have already working code. Andyou need just rewright – Oleg Nov 29 '14 at 19:10