skip to Main Content

I’m struggling with a problem trying to rewrite a url without changeing its content.

I want to display in browser url a different url, but the content still the same

My url is http://fortin.agency/audit-seo/frtcrwl/health_check/report/578/leasingautomobile.ro

And i wanna change it to http://fortin.agency/audit-seo/578/leasingautomobile.ro

What i’ve done:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^frtcrwl/health_check/report/(.*)$ /$1 [L,NC,R=301,NE]

Doesnt work… Any help?

EDIT

578 in the url is dynamic, also the “leasingautomobile.ro”

EDIT #2

Final code:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/(audit-seo)/frtcrwl/health_check/report/(.+)$ [NC]
RewriteRule ^ /%1/%2 [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L] 

Still not working as expected yet as it throws error 404. Can the path remain unchanged? Coz the url in browser link now is perfect. Thanks to @anubhava till now

2

Answers


  1. Change your rule to this and retest inside frtcrwl/.htaccess

    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /audit-seo/frtcrwl/
    
    RewriteCond %{THE_REQUEST} s/+(audit-seo/frtcrwl)/health_check/report/(S+) [NC]
    RewriteRule ^ /%1/%2 [L,R=301,NE]
    
    RewriteRule ^d+/[^/]+/?$ index.php?/health_check/report/$0 [L,NC,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php?/$0 [PT,L,QSA]
    
    Login or Signup to reply.
  2. If you want to be abble to access http://fortin.agency/audit-seo/frtcrwl/health_check/report/578/leasingautomobile.ro from http://fortin.agency/audit-seo/578/leasingautomobile.ro you can use the following rules:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^audit-seo/(.+)$ audit-seo/frtcrwl/health_check/report/$1 [L,NC]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search