Htaccess rewrite rule affects other

Ok, from the beggining.
This is my .htaccess file now:

# RULE 1 - rewriting "/index.php?view=X" to "/X"
 
RewriteEngine On
RewriteCond %{QUERY_STRING} ^view=([^&\s]+)$
RewriteRule ^(?:index\.php|)$ /%1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\s\/]+)/?$ index.php?view=$1&r [L,QSA]

# END OF RULE 1

#RULE 3 - rewriting "index.php" to "/"

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

#END OF RULE 3

And this works pretty good. URLs are SEF and that’s ok.
Now I have other things for accomplish.

Need to solve this:

case 1:
/page.php?page=X to be like this /X

and for posts on page

case 2:
/page.php?page=view&post=ID to be like this /ID (or very similar to this).

Now, interesting thing. I already solved case 1 with this rewrite rule:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=([^&\s]+)$
RewriteRule ^(?:page\.php|)$ /%1? [R=301,L]

RewriteCond %{QUERY_STRING} ^page=([^&\s]+)&page=([^&\s]+)$
RewriteRule ^(?:page\.php|)$ /%1/%2? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\s\/]+)/?$ page.php?page=$1&r [L,QSA]

But it only works if it’s in front of RULE 1 in htaccess file and then RULE 1 isn’t working (gives me 404 page). If this solution is after RULE 1, then RULE 1 works but this doesn’t (URL is solved but my content isn’t displayed).

Any solutions for this?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.