3

I have some URLs like these:

  • http://plutov.by/post/cubique_zf_jquery
  • http://plutov.by/post/mysql_useful_queries

How can I with help of Apache mod_rewrite open the next pages?

  • http://plutov.by/post/main?title=cubique_zf_jquery
  • http://plutov.by/post/main?title=mysql_useful_queries

Also, will be this new rewrite rule work with "one entry point rewriting"?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

Thanks.

2 Answers 2

3

To make the new rewrite rule work with "one entry point rewriting", have your rewriteRules like this:

The QSA flag is mandatory as you are adding a new query string.

RewriteEngine On

RewriteRule ^(post)/([\w\d\-]+)/?$ $1/main?title=$2 [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . index.php [L]
Sign up to request clarification or add additional context in comments.

1 Comment

QSA flag is not mandatory if you don't care about the existing query strings.
3

You can use something like this in your .htaccess:

RewriteRule ^post/(.*)$ post/main?title=$1 [L]

You should keep this rule BEFORE one entry point rewriting rules. If rule will trigger then rewrite rule lookup will be finished (since [L] option specified)

Some modification of paths may be required if you want to use these rules in VirtualHost context

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.