Solved

Help with redirect in htaccess for long php url

Posted on 2009-07-04
9
568 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
 
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now