user3501407
user3501407

Reputation: 457

Getting value with htaccess and pagination for root

This url

example.com/videos/load.php?cat=video-category

would become

example.com/videos/video-category

Also, there is pagination & limit url

example.com/videos/load.php?cat=video-category&p=2&limit=20

it would become

example.com/videos/video-category?p=2&limit=20

(this links also work)

example.com/videos/video-category?p=2
example.com/videos/video-category?limit=20

Also, there is another root url

example.com/videos/load.php?cat=video-category&name=video-name

it would become

example.com/videos/video-category/video-name

Also, there is pagination & limit url

example.com/videos/load.php?cat=video-category&name=video-name&p=2&limit=20

And it would become

example.com/videos/video-category/video-name?p=2&limit=20

(this links also work)

example.com/videos/video-category/video-name?p=2
example.com/videos/video-category/video-name?limit=20

Here is my htaccess (into videos folder)

Options +FollowSymLinks

RewriteEngine on
RewriteBase /videos/

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NE,L]

RewriteCond %{THE_REQUEST} \ /+videos/load\.php\?cat=([^&\ ]+)&?([^\ ]*)
RewriteRule ^ %1?%2 [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ load.php?cat=$1 [L,QSA]

how to do this.. plz help me.. thanks..

Upvotes: 1

Views: 31

Answers (1)

anubhava
anubhava

Reputation: 785276

Have it this way:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /videos/

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NE,L]

RewriteCond %{THE_REQUEST} \s/+videos/load\.php\?cat=([^&\s]+)&name=([^&\s]+)&?(\S*)
RewriteRule ^ %1/%2?%3 [L,R=302]

RewriteCond %{THE_REQUEST} \s/+videos/load\.php\?cat=([^&\s]+)&?(\S*)
RewriteRule ^ %1?%2 [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ load.php?cat=$1&name=$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ load.php?cat=$1 [L,QSA]

Upvotes: 1

Related Questions