charl9cfc Posted May 21, 2013 Share Posted May 21, 2013 Hi All Am trying to mod_rewrite a URL, but unfortunately without any luck. http://mywebsite.com/gallery/mycustom-gallery/linkid417 Should be changed to: http://mywebsite.com/gallery/mycustom-gallery/#417 Where '417' is a dynamic id of an image & mycustom-gallery will also change every-time. I've tried the following rules, but none seems to work... RewriteRule ^/gallery/$1/#([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/y/([0-9]+)$ /gallery/$1/linkid [L,R=301]RewriteRule mycustom-gallery/#.*$ /mycustom-gallery/linkid=417/$1 Regards,Charl Quote Link to comment https://forums.phpfreaks.com/topic/278236-change-character-or-wording-within-a-url/ Share on other sites More sharing options...
theverychap Posted May 21, 2013 Share Posted May 21, 2013 I had to create rewrite rules involving hashes recently, i made notes here: http://tizardsbriefcase.com/625/apache/apache-rewriterule-rewrite-url-to-hash Quote Link to comment https://forums.phpfreaks.com/topic/278236-change-character-or-wording-within-a-url/#findComment-1431367 Share on other sites More sharing options...
Solution jazzman1 Posted May 21, 2013 Solution Share Posted May 21, 2013 I think this is very simple. Try, RewriteEngine On RewriteCond %{REQUEST_URI} ^/gallery/mycustom-gallery/[a-z]+([0-9]+)$ RewriteRule ^(.*)$ /gallery/mycustom-gallery/\%23%1 [R=301,NE,L] Quote Link to comment https://forums.phpfreaks.com/topic/278236-change-character-or-wording-within-a-url/#findComment-1431384 Share on other sites More sharing options...
cpd Posted May 21, 2013 Share Posted May 21, 2013 Could you give us an idea of the bigger picture as this may not be the best way to handle your URL Rewriting if you need to rewrite multiple URLs. Quote Link to comment https://forums.phpfreaks.com/topic/278236-change-character-or-wording-within-a-url/#findComment-1431393 Share on other sites More sharing options...
charl9cfc Posted May 22, 2013 Author Share Posted May 22, 2013 Hi GuysThank you for all the responses.@theverychap - very useful article. Thanks for sharing that resource.@jazzman1 - That worked 100%.Regards,Charl Quote Link to comment https://forums.phpfreaks.com/topic/278236-change-character-or-wording-within-a-url/#findComment-1431498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.