1

I need to redirect /start to /start/index.html and everything else (/anything) to /index.html

What is the correct regex rewriterule for this?

Thanks

octavian
  • 321
  • 2
  • 11

2 Answers2

1

Rewrite condition is needed:

RewriteRule ^start/?$ /start/index.html [R]

RewriteCond %{REQUEST_URI} !^/start/?$
RewriteRule ^([a-zA-Z0-9_-]+)/?$ /index.html [R]

Please considered this link about the [R] flag: https://stackoverflow.com/a/15999177/2007055

Community
  • 1
  • 1
1

I need to redirect /start to /start/index.html and everything else (/anything) to /index.html. What is the correct regex rewriterule for this?

You may try this in one .htaccess file at root directory:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  !index\.html      [NC]
RewriteRule ^start/(.*)  /start/index.html?$1 [L,NC,QSA]

In the rule, anything is passed as a query to index.php and the QSA flag adds the incoming one when present.

To pass anything as a path segment, replace ?$1 with /$1 and remove the QSA flag. It's useless, as any incoming query will be appended automatically.

For permanent redirection, replace [L,NC,QSA] with [R=301,L,NC,QSA]

Felipe Alameda A
  • 11,791
  • 3
  • 29
  • 37