Mod_Rewrite for _edit URL

Hi Folks,


Quick question about using mod_rewrite to rewrite the *_edit url to *_edit?hide_frames=1.



We basically have the rewrite inplace however it seems that mod_rewrite does not inlcude the query string in it's URL when it is tokenised for analysis. This is making life difficult for us to write the appropriate rewrite regex…



We have the following at the moment in the …/web directory directive in apaches httpd.conf file (which by the way does not quite work)…


                RewriteEngine On
                RewriteRule ^(.+)\/_edit$ $1/_edit/?hide_frames=1


We have tried to include a RewriteCond %{QUERY_STRING} !.+$ to exclude the rewrite from firing when there is a query string.......however still no luck...

Any thoughts, suggestions, solution welcome :blink:

Thanks,
A

What is it rewriting to at the moment? Can you post a few examples of how it's behaving?

[quote]What is it rewriting to at the moment? Can you post a few examples of how it’s behaving?
[right][post=“15268”]<{POST_SNAPBACK}>[/post][/right][/quote]



Hi Daniel,



The short answer is that it does nothing…however if I change the rewrite rule to the following it works (albeit it rewrites the URL to…_admin…)


    RewriteRule ^(.+)\/_edit$ $1\/_admin?hide_frames=1


BEFORE REWRITE: http://domain/about/_edi
AFTER REWRITE: http://domain/about/_edi

The issue appears to be with using _edit in both areas of the rewrite rule because I think that the rule is not seeing the query string....

Thanks,
A

[quote]The issue appears to be with using _edit in both areas of the rewrite rule because I think that the rule is not seeing the query string…
[right][post=“15269”]<{POST_SNAPBACK}>[/post][/right][/quote]



That sounds like it could be the issue. You could look at your apache logs to see what is going on, but a simpler solution would be to change your “System Simple Edit Suffix” in the System Settings to “_realedit”.



You can then catch all references to _edit and redirect to _realedit, which should hopefully fix the issues you are having. Keep in mind, if you have hard-coded any references to _edit, you may need to change these.

[quote]That sounds like it could be the issue.  You could look at your apache logs to see what is going on, but a simpler solution would be to change your “System Simple Edit Suffix” in the System Settings to “_realedit”.


You can then catch all references to _edit and redirect to _realedit, which should hopefully fix the issues you are having.  Keep in mind, if you have hard-coded any references to _edit, you may need to change these.

[right][post=“15270”]<{POST_SNAPBACK}>[/post][/right][/quote]



mmmm we had thought about that…however if some zealous person tries simply _realedit then they will get the frames…May be the best hack for the moment…



A :slight_smile:

You could rename it to "_reallySecretEdit" :slight_smile:

[quote]You could rename it to “_reallySecretEdit” :slight_smile:
[right][post=“15272”]<{POST_SNAPBACK}>[/post][/right][/quote]



Hmmmm odder and odder…I tried the "change the suffix for SimpleEdit’ trick and got the following result:



Rewrite rule is as follows:

    RewriteRule ^(.+)\/_edit$ $1\/_sedit?hide_frames=1



BEFORE REWRITE: http://domain/about/_edi
(Login screen appears, url not changed)
(I login to simple edit)
URL REWRITTEN: http://domain/about/_edi
(Invalid warrenty key page appears - we are working with you guys on thsi one)
(hit continue)
URL CHANGED TO: http://domain/about/_edi?
(Frames appear again)

My conclusion is that the hack will work providing we corrent our warrenty key issue.

Thoughts? B)
A