Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with redirect in htaccess for long php url

Posted on 2009-07-04
9
Medium Priority
?
585 Views
Last Modified: 2012-05-07
Hmm using joomla - mod rewrite is on - why doesn't this work? Code from .htaccess

Redirect 301 /index.php?option=com_content&view=article&id=7&Itemid=0 http://mywebsite.com/component/jevents/icalrepeat.detail/2009/07/20/4/2/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE=

RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$
RewriteRule ^123456$ "http\:\/\/mywebsite\.com\/component\/jevents\/icalrepeat\.detail\/2009\/07\/20\/4\/2\/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE\=" [R=301,L]


Thanks
0
Comment
Question by:j-b-t
  • 5
  • 4
9 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 24777072
Well, this code works.
Yet it fires only for http://mywebsite.com/123456
Also, You don't need the "" enclosure, nor \ escaping.
0
 
LVL 11

Author Comment

by:j-b-t
ID: 24778570
Thanks ravenpl - I had a small error in that code..... the code I am trying to get working is:

Redirect 301 /index.php?option=com_content&view=article&id=7&Itemid=0 http://mydomain.com/component/jevents/icalrepeat.detail/2009/07/20/4/2/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE=


RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^index\.php$ "http\:\/\/mydomain\.com\/component\/jevents\/icalrepeat\.detail\/2009\/07\/20\/7\/2\/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE\=" [R=301,L]

I'm sure I've read somwhere there is a problem with the php? (maybe just the questionmark) so I tried:
RewriteRule ^index\.php\?$ "  etc etc - but didn't help
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 24778894
You still haven't said what You entering in the urlbar, and what You expecting.

Still, redirect will not work with query string, so all You can is

Redirect 301 /index.php http://mydomain.com/component/jevents/icalrepeat.detail/2009/07/20/4/2/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE=

For rewrite, You have to match the query string on rewriteCond like

RewriteCond %{QUERY_STRING} ^docid=([0-9]+)
RewriteRule (.*) $1/%1

Now, please tell me what You're expecting from the code, then I'll try to help You with that.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Author Comment

by:j-b-t
ID: 24778905
Thanks Raven - I obviously have no idea. My apologies

I want to redirect the page called
http://www.mydomain.com/index.php?option=com_content&view=article&id=7&Itemid=0
to
http://www.mydomain.com/component/jevents/icalrepeat.detail/2009/07/20/4/2/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE=
( So when you click on a link to the first url you essentilly end up at eth second)
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 24778917

RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=7&Itemid=0
RewriteRule index.php /component/jevents/icalrepeat.detail/2009/07/20/4/2/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE= [L,R=301]

Strip the R=301 from flags, if You want to hide the redirection from user.
Redirects are usually used for bulk matched redirects, though I cannot find any dependencies between original and redirected urls??
0
 
LVL 11

Author Comment

by:j-b-t
ID: 24778954
Thanks - I must be doing something wrong still

Here is my entire .htaccess file -  amybe something else is interfering.. ?

when I add your code with corrected domain - i'm not getting a redirect - just goes to the original page/article - your're right I don't need the 301(PS - Ive checked that mod_rewrite is on in joomla and tried a few variations of the code - but I'm just guessing really

#####################################################
#  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

# RewriteBase /

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

#
########## End - Joomla! core SEF Section


RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=7&Itemid=0
RewriteRule index.php/component/jevents/icalrepeat.detail/2009/07/20/4/2/YjVhOWExYWNjNjI5ZmNlZDIzNzEzMWIzNDU2ZmU3NWE= [L,R=301]

0
 
LVL 43

Accepted Solution

by:
ravenpl earned 2000 total points
ID: 24778962
> RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
Have You changed it to Your actual domain? If You have multiple, please comment it out.

> RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
Try stripping the L flag - it causes rewrite engine to terminate processing - and the .* matches anything.
0
 
LVL 11

Author Comment

by:j-b-t
ID: 24779002
Thanks  - I really can't get this working - I really can't seem to work out why.

I've found a module that seems to have a work around momentarilly (http://extensions.joomla.org/extensions/structure-&-navigation/url-redirection/7189/details) ... but I'm still struggling a bit with it.

But many thanks
0
 
LVL 11

Author Closing Comment

by:j-b-t
ID: 31599738
Didn't solve problem - but certainly gave me enough info to work through it and find an alternative soln - thanks for your patience!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month6 days, 8 hours left to enroll

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question