Htaccess skip=404 error

Hello,
I’m trying to skip the next 5 rules and conditions and it seems to work, but the problem is that I get a 404 error when I try to access the page I’m checking [noparse]http://lamevideos.tk/component/hwdvideoshare/upload?Itemid=402[/noparse]
The rules that I’m skipping should make a link like this
[B][noparse]http://lamevideos.tk/component/hwdvideoshare/viewvideo/783/music/rurutia-lost-butterfly?Itemid=402[/noparse][/B]
to look like this
[B][noparse]http://lamevideos.tk/viewvideo/783/music/rurutia-lost-butterfly[/noparse][/B]
Anyone can tell me what I’m doing wrong?

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{REQUEST_URI} ^/component/hwdvideoshare/upload$
RewriteRule (.*) - [S=5,L]

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{QUERY_STRING} ^Itemid=([0-9]+)$
RewriteRule ^(.*) $1? [L,R=301]
RewriteRule ^home/magnxpyr/public_html(.*) $1 [L,R=301]
RewriteRule ^component/hwdvideoshare(.*) $1 [L,R=301]

Thanks

A few changes:


RewriteCond %{HTTP_HOST} ^lamevideos\\.tk$
RewriteCond %{REQUEST_URI} ^/component/hwdvideoshare/upload$
RewriteRule (.*) - [S=3,L]

RewriteCond %{HTTP_HOST} ^lamevideos\\.tk$
RewriteCond %{QUERY_STRING} ^Itemid=([0-9]+)$
RewriteRule ^(.*)$ $1? [L,R=301]
RewriteRule ^home/magnxpyr/public_html(.*)$ $1 [L,R=301]
RewriteRule ^component/hwdvideoshare(.*)$ $1 [L,R=301]

1. use lamevideos\.tk instead of lamevideos.tk, since it is a regular expression and . in a regular expression means “any character”. Both variants work, but with the backslash to indicate you want to match a dot specifically instead of just any character is better.

2. The [S] flag only skips RewriteRules, not RewriteConds. So you need to change 5 to 3

3. ^(.) isn’t specific enough, make it ^(.)$ (same goes for the other two rules)

Other than that I don’t see why this shouldn’t work. Maybe your browser is caching redirects. Have you tried clearing your cache and restarting your browser?

FYI. The RewriteConds only apply to the RewriteRule directly after it, not the two rules that follow that rule. If you want to have the RewriteConds apply to the other two rules as well you need to duplicate them like so


...

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{QUERY_STRING} ^Itemid=([0-9]+)$
RewriteRule ^(.*)$ $1? [L,R=301]

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{QUERY_STRING} ^Itemid=([0-9]+)$
RewriteRule ^home/magnxpyr/public_html(.*)$ $1 [L,R=301]

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{QUERY_STRING} ^Itemid=([0-9]+)$
RewriteRule ^component/hwdvideoshare(.*)$ $1 [L,R=301]

I made the changes you said, but is still not working (404 Not Found)

Does it work if you remove the $ at the end of ^/component/hwdvideoshare/upload$ ?

nop

Could you post the complete .htaccess please?

I’m using joomla 1.6 so is quite big; but, so far, everything works fine

Options +FollowSymLinks
RewriteEngine On

AddHandler application/x-httpd-php5 .php
Action application/x-httpd-php5 "/cgi-bin/php"
SuPHP_ConfigPath /home/magnxpyr/public_html

# force www
RewriteCond %{HTTP_HOST} ^magnxpyr.com$ [OR]
RewriteCond %{HTTP_HOST} ^old.magnxpyr.com$ [OR]
RewriteCond %{HTTP_HOST} ^static.magnxpyr.com$ [OR]
RewriteCond %{HTTP_HOST} ^test.magnxpyr.com$ [OR]
RewriteCond %{HTTP_HOST} ^vid.magnxpyr.com$ [OR]
RewriteCond %{HTTP_HOST} ^video.magnxpyr.com$ [OR]
RewriteCond %{HTTP_HOST} ^fgdfgd.magnxpyr.com$
RewriteRule ^(.*) http://www.magnxpyr.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^([0-9]+)-([a-zA-Z]+)(.*) http://www.magnxpyr.com/$2$3 [R=301,L]

#301 Redirect Entire Directory
RedirectMatch 301 news/anime(.*) /anime/news$1
RedirectMatch 301 news/gaming(.*) /gaming/news$1
RedirectMatch 301 news/movies(.*) /film/news$1
RedirectMatch 301 news/software(.*) /itech/news$1
RedirectMatch 301 review/gaming(.*) /gaming/review$1
RedirectMatch 301 review/software(.*) /it/review$1
RedirectMatch 301 review/movie(.*) /film/review$1
RedirectMatch 301 review/anime(.*) /anime/review$1
RedirectMatch 301 it/news(.*) /itech/news$1
RedirectMatch 301 it/review(.*) /itech/review$1
RedirectMatch 301 ^/terms http://www.magnxpyr.com/tos

RedirectMatch 301 ^/component/hwdphotoshare/(.*) http://lameart.tk/$1
RedirectMatch 301 ^/image/(.*) http://lameart.tk/$1
RedirectMatch 301 ^/image?n(.*) http://lameart.tk$1

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{REQUEST_URI} ^/component/hwdvideoshare/upload$
RewriteRule (.*)$ - [S=3,L]

RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteCond %{QUERY_STRING} ^Itemid=([0-9]+)$
RewriteRule ^(.*)$ $1? [L,R=301]
RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteRule ^home/magnxpyr/public_html(.*)$ $1 [L,R=301]
RewriteCond %{HTTP_HOST} ^lamevideos.tk$
RewriteRule ^component/hwdvideoshare(.*)$ $1 [L,R=301]

RedirectMatch 301 ^/video/(.*) http://lamevideos.tk/$1
RedirectMatch 301 ^/video?(.*) http://lamevideos.tk$1

RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^anime(.*) http://anime.magnxpyr.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^gaming(.*) http://gaming.magnxpyr.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^film(.*) http://film.magnxpyr.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^movie(.*) http://film.magnxpyr.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^software(.*) http://itech.magnxpyr.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^itech(.*) http://itech.magnxpyr.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*).magnxpyr.com$
RewriteRule ^u(.*) http://maeyo.tk$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^it.magnxpyr.com$
RewriteRule ^(.*) http://itech.magnxpyr.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^u.magnxpyr.com$
RewriteRule ^(.*) http://maeyo.tk/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.magnxpyr.com$
RewriteRule ^/news/(.*) http://www.magnxpyr.com [R=301,L]
RewriteCond %{HTTP_HOST} ^www.magnxpyr.com$
RewriteRule ^/review/(.*) http://www.magnxpyr.com [R=301,L]

## 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 base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\\([^)]*\\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

# RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.

The last RewriteRule there also acts on /components. Maybe something’s going wrong over there?
I’ve never used joomla myself so I’m not really sure what’s going on in that .htaccess and what joomla actually needs.

I assume you are you on lamevideos.tk when you make that request? Not [noparse]www.lamevideos.com[/noparse] or any other domain?

seems like you are right. you have any idea how I can make it work?
This part is removing index.php from all joomla’s links so I’d like to still work

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.

yep, on lamevideos.tk

Seems like if I comment this line everything works fine and it solves many other problems. But this will not result in a security issue?

RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\\.(php|html?|feed|pdf|vcf|raw))$ [NC]

I’m sorry, but I’ve never worked with Joomla, so I’m not sure, but I don’t think it would be a security problem. At least I don’t see how it could be. You’re probably better of asking that question in a joomla forum where people can answer with certainty though.