Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dynamic .htaccess redirect

Featured Replies

Hi Guys,

 

I'm trying to perform the following single redirect:

 

http://www.site.co.uk/index.php?option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15

 

301 redirect to:

 

http://www.site.co.uk

 

I've been researching this and have tried the following:

 

RewriteCond %{QUERY_STRING} ^option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15$
RewriteRule ^index\.php$ http://www.site.co.uk/ [L,R=301]

 

But this results in:

 

http://www.site.co.uk/?option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15

 

Any advice would be appreciated :D

Edited by wkdfx

I find PHP to be a lot easier when it comes to simple things like this. Why not just use your index.php, and at the top put

if(!empty($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15') {
header('Location: http://www.site.co.uk/');
die();
}

Hi Guys,

 

I'm trying to perform the following single redirect:

 

http://www.site.co.uk/index.php?option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15

 

301 redirect to:

 

http://www.site.co.uk

 

I've been researching this and have tried the following:

 

RewriteCond %{QUERY_STRING} ^option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15$
RewriteRule ^index\.php$ http://www.site.co.uk/ [L,R=301]

 

But this results in:

 

http://www.site.co.uk/?option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15

 

Any advice would be appreciated :D

 

Just add this line to your .htaccess:

 

redirect 301 /index.php?option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15 http://www.site.co.uk/

Edited by Spitfire

  • Author

I find PHP to be a lot easier when it comes to simple things like this. Why not just use your index.php, and at the top put

if(!empty($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15') {
header('Location: http://www.site.co.uk/');
die();
}

 

Thanks Jay, this worked well! I checked to see the type of redirect and it was a 302 so after a little research included the following line which did the trick:

 

header('HTTP/1.1 301 Moved Permanently');

 

I'm still interested to see how it would be done through htaccess if anyone has any ideas?

Edited by wkdfx

  • Author

Just add this line to your .htaccess:

 

redirect 301 /index.php?option=com_content&view=section&layout=blog&id=3&Itemid=9&limitstart=15 http://www.site.co.uk/

 

Unfortunately this won't work as the URL contains variables :(

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.