0

I am trying to convert this url

http://127.0.0.1/kurumsal/index.php?sayfa=referans&page=2

to this

http://127.0.0.1/kurumsal/index/sayfa/referans/page/2/

but not every page has pagination which refers to page=2 query string. i want to just use first part of query string if 'page' query string do not exist.

So it would be http://127.0.0.1/kurumsal/index/sayfa/referans/ without pagination query string.

followed some tutorials but no luck, here is my htaccess

RewriteEngine On
RewriteCond %{QUERY_STRING} !(^|&)page=($|&)
RewriteRule ^sayfa/([^/]*)/([^/]*)/$ /kurumsal/index.php?sayfa=$1&page=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^sayfa/([^/]*)/$ /kurumsal/index.php?sayfa=$1 [L]
2
  • Pls specify where the htaccess file is placed? Commented Jun 24, 2016 at 11:23
  • @WEBDEVPR project root folder which is /kurumsal/ Commented Jun 24, 2016 at 11:32

3 Answers 3

1

Try using this rule:

RewriteEngine On
RewriteRule ^kurumsal/index/sayfa/([^/]*)/page/([^/]*)$ /kurumsal/index.php?sayfa=$1&page=$2 [L]
Sign up to request clarification or add additional context in comments.

Comments

1

You can use this rule in root/.htaccess :

RewriteEngine on

RewriteCond %{THE_REQUEST} /kurumsal/index\.php\?sayfa=([^\&]+)(?:&page=)?(.*?)\sHTTP [NC]
RewriteRule ^ /kurumsal/index/sayfa/%1/%2? [L,R]
RewriteRule ^(?:kurumsal/)?index/sayfa/([^/]+)/?(.*?)/?$ /kurumsal/index.php?sayfa=$1&page=$2 [L]

Comments

1

Try this

RewriteEngine On
RewriteBase /kurumsal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/sayfa/([^/]*)/page/([^/]*)/$ /kurumsal/index.php?sayfa=$1&page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/sayfa/([^/]*)/$ /kurumsal/index.php?sayfa=$1 [L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.