Hi i hve been running forum for quite while and people started using it for spam etc and now even though i took it down i still got like 100 clicks day for threads that dont exist and the forum is not existing too.
I tired of seeing this crap in my piwik stats i want to move it with mod rewrite so every time someone access
site.com/samples/forum he goes soemwhere else like actual redirect to fbi.com etc. better without showing my url of couse or just to some non existing folder so it does not triger my stats.
You're probably looking for something along the lines of:
RewriteEngine on
RewriteRule /samples/forum http://othersite.com/path [L,R]
(of course can flex if you need patterns, or for different paths) There are tons of handy options that you can use, all documented in Apache's documentation.
Related
I had a folder that contained 15000 images, i decided to put them in 10 folders.
The initial folder url where i had my 15000 images was :
www.mysite.com/images/games/
And the new folders' urls are :
www.mysite.com/images/games/1/
www.mysite.com/images/games/2/
www.mysite.com/images/games/3/
www.mysite.com/images/games/4/
www.mysite.com/images/games/5/
www.mysite.com/images/games/6/
www.mysite.com/images/games/7/
www.mysite.com/images/games/8/
www.mysite.com/images/games/9/
www.mysite.com/images/games/10/
How can I redirect my images to match their correct folder to get rid of 404 errors?
Given your expansion in the comments above:
I know which images go to which folder, but its a big list
I suggest putting that list in a text file, and using find and replace (or awk?) to transform that list into mod_redirect rules, e.g.
Redirect /images/games/oldname /images/games/8/oldname
Then paste those into a configuration file. If there's no actual algorithm that determined how these got sorted into directories, there's no program that can redirect requests, because it would require a formula to work from.
Much as I love to cite When Not To Use Rewrite, this is actually a case where mod_rewrite is called for.
You don't say how you distributed your images between the ten new directories, but I am assuming the images were numbered (e.g. 00001.png, 00002.png, ... 15000.png). Then you used the last digit to determine which image goes into which folder, i.e. 00001.png goes into the 1 directory, all the way up to 15000.png which goes into the 10 directory (I think - why didn't you name it 0?) That's what you did, right?
You don't mention what server you're using on this site, so I'm going to assume you're using Apache, right? In that case you'd edit the appropriate configuration file (I started trying to assume which one, but honestly it could be any one of four I can think of, depending on whether you have edit rights to the vhost configuration, or root on the server, or if you're on a Debian-flavored or Red-Hat-flavored distro, you are using Linux, right? You didn't say.) You'd make sure there's a RewriteEngine On in there somewhere, then you'd do something like this:
RewriteRule ^/images/games/(\d+)(\d)\.png$ /images/games/$2/$1$2.png
...except that you named the directory 10 instead of 0, so all the ones ending in 0 are going to get misdirected. Maybe we should try this?
RewriteRule ^/images/games/(\d+0)\.png$ /images/games/10/$1.png [L]
RewriteRule ^/images/games/(\d+)([1-9])\.png$ /images/games/$2/$1$2.png [L]
...and catch the 0s first, then everything else.
I'd check this answer, but you haven't given us anywhere near enough information to know how.
Gang,
Long time sysadmin but first time poster to this excellent site, so, please be gentle.
I am not strong at REGEX yet and trying to do two things at once on our internally hosted "mediawiki" site.
We are running an otherwise pretty plain jane LAMP stack (centOS 5.x, Apache 2.x, PHP 5.x). We are root. We are using /etc/httpd/conf.d/wiki.conf and not using .htaccess. The physical path is /var/www/html/wiki/
I have partially successful results with some combination of the below, but I am not good enough to get it all the way there. I know that there are some mod_write studs on this site that I am hoping to avail.
I am following this recipe https://www.mediawiki.org/wiki/Manual:Short_URL/Apache so as to shorten URL's from www.example.com/wiki/index.php?=title=Garden_Store to www.example.com/wiki/Garden_Store
still allow the use of www.example.com/wiki/index.php?=title=Garden_Store should the user should choose to type out that syntax of URL. (I believe that is possible with mediawiki to use both style URL's at the same time. If it is impossible, then I will be forced to skip the short URL and use the style with the variable in it.)
Last, string special characters from the URL in the example like www.example.com/wiki/index.php?=title=Garden,_Store! ought to be this www.example.com/wiki/index.php?=title=Garden_Store .
Another example of that might be www.example.com/wiki/index.php?=title=Garden_Store,_Inc. ought to be www.example.com/wiki/index.php?=title=Garden_Store_Inc
One last example, us to make sure that I am communicating well, would be getting this "/title=Garden%20Store,%20Inc" but wanting this "/index.php?title=Garden%20Store%20Inc" as I know that the spaces are replaced with underscores inside of mediawiki.
Thanks so much for walking a newbie the last bit to the finish line on this one.
Cheers.
Jason
Something like the following rules should do what you need:
RewriteRule ^(.*)\ (.*)$ $1\_$2 [L]
RewriteRule ^(.*)[^a-zA-Z0-9\/\._](.*)$ $1$2 [L]
First rule does replace space with underscore and the other line strips all chars you don't want to stay in the resulting URL. Note, your will probably need to add some more, if you want.
New OScommerce user.
I've been fiddling around with Chemo's Ultimate SEO add-on the last few days. I've mostly got it working (minus one bizarre redirect loop for category pages?) but I'm a little disappointed in the limited options for formatting URLs.
I'm seeing:
http://www.website.com/category-awesomeproduct-p-1735.html
When we'd really like to do something more in line with:
http://www.website.com/category/awesomeproduct
What are my options? Am I out of luck?
I fear that the stock URL parameters are rigidly defined and that there's no way to hide the less friendly ones.
After researching this for quite awhile, and receiving no answers here, I believe the answer is: no
The view controller expects that data and it can't be omitted, even with customizations installed.
I'm trying to clear up a grey area about this much talked about topic...
Like most devs, I've made some pretty URLs with mod_rewrite. My sites internal links point to the pretty URLs and things are working nicely.
But, I can still access the old URL if I point to it directly.
Now, this is most certainly going to cause duplicate content issues so after doing some research it seems that 301 redirects are the way to go.
But.... and here's the grey bit...
If you are working on a site with thousands of URLs, what's best practice to achieve this? I don't wantto list 1k+ lines in .htaccess I thought of a regexp in my rewrite rule, but my pretty URLs have names from the database in them... and I can't access that from .htaccess :)
Have I hit a dead end? Is there a way around this? Would Google's canonical tag be a possibility??
Well, I don't know if this is the "definitive" answer, but I have a bunch of "functional" URLS like:
http://www.flipscript.com/product.aspx?cid=7&pid=42&ds=asdjlf8i7sdfkhsjfd978
but I remap the URLs, link to them and list them in my site map as:
http://www.flipscript.com/ambigram-ring.aspx
I haven't seen ANY evidence that identical URLS pointing to the same content within the same domain has any negative impact on SEO.
In fact, over the past year, I have climbed to the #1 position on Google with this in place for my primary keyword.
My theory about why this should be so is that Google applies the duplicate content penalty for entire "clone sites", not for just linking with different URLs to the same content within a single site.
A quick dirty way would be to re-route everything on the site via a PHP file that checks to see if the path is still valid, querying the database if necessary. Use a 301 redirect if the path has permanently moved. Soon enough these "grey urls" should hardly ever come across, and indexes should be updated across search engines. At which point you can remove the router.
If you could specify what your "grey url" looks like I may be able to suggest a better alternative.
"Would Google's canonical tag be a possibility??" -- Why not?
--> It automatically transfers page rank
--> Google recommends canonical tag even if the content differs slightly but is more or less similar.
--> Too many 301 redirects to pages within site are bad for SEO (my personal experience with Bing).
--> Too may 301 redirects increase the effective load time of content for your users (especially bad if the ping times from their location to your server is high).
I'd like to strip a URL of it's query string using mod_rewrite but retain the values of the querystring, for example, id like to change:
http://new.app/index.php?lorem=1&ipsum=2
to a nice clean:
http://new.app/
but retain the values of lorem and ipsum, so inside index.php:
$_GET["lorem"]
would still return 1 etc.
This is my first dabble with mod_rewrite so any help is greatly appreciated, and if you could explain exactly how your solution works, I can learn a little for next time too!
Thanks!
As Roland mentioned, you don't seem to understand the way rewriting works. It's typically done using Apache mod_rewrite in .htaccess, which silently rewrites the pretty URLs to the php script as /index.php?lorem=1&ipsum=2
Even Joomla uses .htaccess, except it has a single rewrite rule that passes EVERYTHING to a PHP script which does the actual rewriting in PHP.
What you are not understanding is that something still needs to exist in the "pretty" version for the php script to pull the value of $_GET["lorem"]
So it would be like http://new.app/lorem/ or http://new.app/section/lorem which would then (using mod_rewrite in .htaccess) rewrite TO the php script.
I don't understand exactly what you want. Your first URL is the external form, which the users see and can type into their browsers.
The second form has almost all information stripped, so when you send that to a server, how is the server supposed to know that lorem=1&ipsum=2?
If your question is really
How do I make the URLs in the browser look nice, even if the user is somewhere deep in the website clicking on URLs that carry lots of information?
then there are two solutions:
You can pass the information in small bits to the server and save them all in a session. I don't like that because then the user cannot take the URL, show it to a friend and have him see the same page.
You can have your entire web site in an HTML <frameset> containing only one <frame>. That way, the URL of the top-level window will not change, only the inner URL (which is not displayed by the browser) will.