Replacing ? in PHP GET.

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
Hello,

So I got .htaccess to forward anything like ?id=1 to /id/1
But now I'm getting "Error 404, Not found.".

Is there something wrong with my .htaccess?


Code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
 
# external redirect from /view.php?id=1 to /view/id/1
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+([^.]+)\.php\?([^=]+)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [L,R=301]
 
# internal forward from /view/id/1 to /view.php?id=1
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /$1.php?$2=$3 [L,QSA]
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,398
962
What's with the internal rewrite?

Try:
Code:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /view.php/$1 [L]
</IfModule>
 

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
When I do /page/blog, it still takes me to the main page (/page/main).
This is because $_POST['page'] isn't set.

c2ce8fa74ad4e0fbb7c3a968268c25b1.png
 

GarettM

Posting Freak
Aug 5, 2010
833
136
This Should work Have not Tested it though
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
 
    # Remove file extension
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.*)$ $1.php [L]
 
    # Replace blog.php?id={id} to blog/{id}
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^blog(|/)$ blog.php [L]
    RewriteRule ^blog(|/)([a-zA-Z0-9_-]+)(|/)$ blog.php?id=$1 [NC]
   
</IfModule>
 

Users who are viewing this thread

Top