php - .htaccess returning mod_rewrite redirect to the index page of the www folder of wamp -


i trying create "pretty urls dynamically created pages. desire render pages index page.

i working on computer using wamp 2.5/apache 2.4.9

the apache httpd.conf set to:

listen 0.0.0.0:7080 listen [::0]:7080 documentroot "c:/wamp/www/" servername localhost:7080 

i have tried several different approaches have resulted in blank page returning 404 error page. code below returns index.php in /www/ folder in wamp.

this non-working .htaccess code:

# turn rewrite engine options +followsymlinks  rewriteengine on  #rewritecond %{request_filename} !-d #rewritecond %{request_filename} !-f #rewritecond %{request_filename} !-l  # pages  rewriterule ^([a-za-z0-9]+)$ index.php?topic=$1  # rewrite www. rewritecond %{http_host} ^localhost:7080/demo [nc] rewriterule ^(.*)$ http://www.localhost:7080/demo/$1 [r=301,nc] 

the clupret line of code believe:

rewriterule ^([a-za-z0-9]+)$ index.php?topic=$1

which thinking sort of path issue not sure... assistance appreciated.

the url in address is: http://localhost:7080/demo/test demo site folder in wamp/www/

http://localhost:7080/demo/test/ (with forward slash) returns 404 error.

  1. your htaccess lacking rewrite base. after: rewriteengine on

    add rewritebase /demo/

  2. it strictly not allowing trailing slashes replace line: rewriterule ^([a-za-z0-9]+)$ index.php?topic=$1 withthis code:

    rewritecond %{request_uri} !-f

    rewriterule ^([a-za-z0-9]+)$ index.php?username=$1 [n,l]

this allow urls ending trailing slashes force redirect url.

  1. remove last line:

    http://www.localhost:7080. leave just: /demo/$1 [r=301,nc]

the second last line not doing lot. can , advice away it.

please remember when leaving localhost environment online host, replace incidence of "/demo/" "/"

your final htaccess should someting this:

# turn rewrite engine options +followsymlinks  rewriteengine on  rewritebase /demo/  #rewritecond %{request_filename} !-f #rewritecond %{request_filename} !-l #rewritecond %{request_filename} !-d  # pages  #rewritecond %{request_uri} !-f rewriterule ^([a-za-z0-9]+)$ index.php?username=$1 [n,l]  # rewrite www. rewriterule ^(.*)$ /demo/$1 [r=301,nc] 

i hope helps


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -