1

I know this might be a stupid question.

if I have an php or html code like this.

  <a href="http://localhost/site/author/detail.php?id=<?php $row['id']?>&name=<?php $row['name']?>">link</a>

is possible to rewrite it to something like below using htaccess?

http://localhost/site/author/(value for id here)/(value for name here)/

i've tried this.

RewriteRule ^author/(.*)$ ./author/detail.php?id=$1&name=$2

but it didnt work.

http.conf I already uncomment the module by removing #.

LoadModule rewrite_module modules/mod_rewrite.so
<Directory />
    AllowOverride none
    Require all denied
</Directory>
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
 Require all granted
</Directory>

anyhelp would be great. Thank you.

blitzen12
  • 1,350
  • 3
  • 24
  • 33

1 Answers1

1

Place this rule in /site/author/.htaccess file:

RewriteEngine On
RewriteBase /site/author/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ detail.php?id=$1&name=$2 [L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • still not working and also my environment is windows 7 32bit. I also follow the instruction from http://stackoverflow.com/questions/17162214/htaccess-not-working-on-localhost-with-xampp but no luck. – blitzen12 Apr 05 '14 at 02:17
  • What is location of this htaccess and what URL did you use for testing? – anubhava Apr 05 '14 at 04:48
  • it is located in root folder of the project. and I use the URL I posted. I just change the /site/ to the name of my project. – blitzen12 Apr 05 '14 at 06:27
  • I think you need `RewriteBase /site/` (change to your folder name). Also is `/site/author/` a real directory? – anubhava Apr 05 '14 at 07:22
  • yes..they are real.. it's like site is the name of the project. and author is the sub directory. I'll edit my question to show some of http.conf I tried RewriteBase /site/ but still not working. I'm stack for this for days now. – blitzen12 Apr 05 '14 at 07:54
  • ok see updated code, remember it goes in `/site/author/.htaccess` file. Also tell me what exact URL do you see in your browser. – anubhava Apr 05 '14 at 09:35
  • when I to go to http://localhost/site/author/10/blitzen12, I guess it worked, I can get the value for id which is 10 but the only problem now is that the designed is ruined. all css and js is not found. – blitzen12 Apr 05 '14 at 10:29