0

My site previously uses URL's like this: /folder/page

Previously, you could prepend 'panel' in the URL to edit the current page: /panel/folder/page

We upgraded our CMS, and the new URL to edit the page is in this format: /panel/#/pages/show/folder/page

I am trying to add a rewrite rule so that we can still use the old way, but can't get it to work:

RewriteCond %{REQUEST_URI} !^/panel/#/
RewriteRule /panel(.*) /panel/#/pages/show/$1

Is there a way to do this? A 301 redirect should work too, I think.

Edit: here is my existing .htaccess:

RewriteEngine on

RewriteBase /

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
ebi
  • 4,862
  • 6
  • 29
  • 40
  • You can't parse or rewrite hashtag since it's client side only. Anyway, you can redirect with a hashtag. You can replace your two lines by this rule: `RewriteRule ^panel/(.+)$ /panel/#/pages/show/$1 [R=301,L,NE]` – Justin Iurman Apr 24 '15 at 21:14
  • Thanks for your answer. Unfortunately that doesn't seem to work though, it breaks some stuff on the client side. – ebi Apr 24 '15 at 21:31
  • If it is redirecting to the path that the CMS needs, how can it break anything? – Mike Rockétt Apr 25 '15 at 05:24
  • `RewriteRule "^/?panel/([^\#]+)$" "/panel/#/pages/show/$1" [R=301,L,NE]` wo RewriteCond – Deadooshka Apr 25 '15 at 09:55
  • @Deadooshka that causes a redirect loop – ebi Apr 26 '15 at 01:47
  • `RewriteCond %{REQUEST_URI} !^/panel/#/`; The `%{REQUEST_URI}` never receives URLs with `#` anchors. – hjpotter92 Apr 26 '15 at 01:49
  • need to track a real URL-string that RewriteRule gets http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging – Deadooshka Apr 26 '15 at 07:09

1 Answers1

0

Since "panel" is already used, I ended up using this redirect rule:

RedirectMatch 301 /admin(.*) /panel/#/pages/show/$1
ebi
  • 4,862
  • 6
  • 29
  • 40