Question

i know that this question was already posted a lot of time, i ve already search but i could not find what i need.

i'm working on my htaccess to add seo freindly link, for example:

Options -MultiViews
RewriteBase /
RewriteRule ^list$ list.php [L]

that work perfectly, the problem apper when i try to add vars, for exmpale i need that the url: pages.php?id=terms become: page/terms

so i've try in many way but don't work, this is what i try:

Options +FollowSymLinks
RewriteRule ^list$ list.php [L]
RewriteRule ^page/(.*)/ pages.php?x=$1 [L]

PS: what is the difference between +FollowSymLinks and -MultiViews?

Était-ce utile?

La solution

Add QSA flag:

Options +FollowSymLinks -MultiViews

RewriteRule ^list$ list.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/([^/]+)/?$ pages.php?x=$1 [L,QSA,NC]
  • QSA (Query String Append) flag preserves existing query parameters while adding a new one.
  • Information about Apache's content negotiation.
  • +FollowSymLinks makes Apache follow symbolic links.
  • -MultiViews make turns off content negotiation

For CSS/JS/image:

  1. Use absolute path in your css, js, images files rather than a relative one. Which means you have to make sure path of these files start either with http:// or a slash /.
  2. OR else You can try adding this in your page's header: <base href="/" />
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top