0

I'm trying to make my .htaccess better and easy to update in the future

it's currently

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^register?$ register.php [QSA]
RewriteRule ^logout?$ logout.php [QSA]
RewriteRule ^contact?$ contact.php [QSA]
RewriteRule ^search?$ search.php [QSA]
RewriteRule ^settings?$ settings.php [QSA]

RewriteRule ^about?$ page.php?url=about [QSA]
RewriteRule ^privacy?$ page.php?url=privacy [QSA]
RewriteRule ^terms?$ page.php?url=terms [QSA]

Is there was to make it like - this to;

RewriteRule ^register?$ register.php [QSA]
RewriteRule ^logout?$ logout.php [QSA]
RewriteRule ^contact?$ contact.php [QSA]
RewriteRule ^search?$ search.php [QSA]
RewriteRule ^settings?$ settings.php [QSA]
  1. if abc.php php file exists, it can automatically supports /abc URL and display abc.php? otherwise the list will get really long..

  2. is there a way to make;

RewriteRule ^about?$ page.php?url=about [QSA]
RewriteRule ^privacy?$ page.php?url=privacy [QSA]
RewriteRule ^terms?$ page.php?url=terms [QSA]

into 1 line? something like RewriteRule ^(terms|privacy|about)?$ page.php?url=(terms|privacy|about)[QSA]

My really new with htaccess, I really appreciate your input

Gulec
  • 51
  • 1
  • 2
  • Does this answer your question? [Remove .php extension with .htaccess](https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – CBroe Sep 08 '20 at 06:47
  • And for the second part, look into “backreferences”. https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriterule – CBroe Sep 08 '20 at 06:48
  • Why don't people read the documentation of the tools they use? – arkascha Sep 08 '20 at 11:58
  • What do you think the `?` is doing in `^register?$`? This argument is a _regular expression_. – MrWhite Sep 09 '20 at 19:03

0 Answers0