1

I am trying to rewrite the URL from the .htaccess file, tried a lot but ended up with frustration.

.htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond    ^suba/?$    resources/uploads/releases/zipfiles/1484883480/index\.html [NC, C]
        RewriteRule ^ index.php [L]

I just want to open this with the short URL like this to make it more SEO friendly,
http://dittmagasin.no/release.

I have referred to the following posts:

  1. URL rewriting with PHP
  2. URL rewriting for beginners

Any help will be appreciated. Thanks

Suba Sah
  • 157
  • 8

1 Answers1

1

You can use:

RewriteEngine On

RewriteRule ^release/?$ resources/uploads/releases/zipfiles/1484883480/index.html [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • http://dittmagasin.no/release, doesnt load the CSS, JS and Image. Could you help me with that please ? – Suba Sah May 26 '17 at 10:48
  • You can notice the difference between http://dittmagasin.no/release and http://dittmagasin.no/resources/uploads/releases/zipfiles/1484883480/index.html – Suba Sah May 26 '17 at 10:48
  • That is because of relative paths in your css/js/image. You need to add this just below `` section of your page's HTML: `` – anubhava May 26 '17 at 10:51
  • As we generate(1484883480) automatically each time a release is uploaded to the system, do we have any solution without including this number? – Suba Sah May 26 '17 at 11:01
  • If `1484883480` is generated dynamically then how come `css` folder is inside `1484883480` ? – anubhava May 26 '17 at 11:03
  • As I have mentioned earlier that this folder name(zip file) is generated while uploading the magazine. `1484883480` is folder name and so it has `css`, `js` and `image` within this too. – Suba Sah May 26 '17 at 11:05
  • 1
    As I mentioned earlier also that problem is with your use of relative paths. Rewrite rule part is done. It is up to you how you want to tell browser to find css/js/images. There are 2 solutions: you can either provide full path that starts with `/` or you can use `base` tag as I suggested. – anubhava May 26 '17 at 11:08
  • 1
    Thanks a lot. I would try – Suba Sah May 26 '17 at 11:10