V
V
vladislav9972021-03-28 10:10:20
htaccess
vladislav997, 2021-03-28 10:10:20

How to use htaccess to make /post-name instead of /article.php?title=post-name?

Tell me, how can I make /post-name (or /article/post-name) through htaccess instead of /article.php?title=post-name ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-03-28
@shambler81

/article.php?title=post-name => /post-name

RewriteCond %{QUERY_STRING} (?:^|&)title\=post\-name(?:$|&)
RewriteRule ^article\.php$ /post\-name? [L,R=301]

/article.php?title=post-name => /article/post-name
RewriteCond %{QUERY_STRING} (?:^|&)title\=post\-name(?:$|&)
RewriteRule ^article\.php$ /article/post\-name? [L,R=301]

well, the option with variables in the title
RewriteCond %{QUERY_STRING} (?:^|&)title\=(.+)(?:$|&)
RewriteRule ^article\.php$ /article/%1? [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question