-
Star
(1,913)
You must be signed in to star a gist -
Fork
(558)
You must be signed in to fork a gist
-
-
Save ScottPhillips/1721489 to your computer and use it in GitHub Desktop.
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ | |
#Redirect a sub folder to another site | |
Redirect 301 /subfolder http://www.domain.com/ | |
#This will redirect any file with the .html extension to use the same filename but use the .php extension instead. | |
RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php | |
## | |
#You can also perform 301 redirects using rewriting via .htaccess. | |
## | |
#Redirect from old domain to new domain | |
RewriteEngine on | |
RewriteBase / | |
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] | |
#Redirect to www location | |
RewriteEngine on | |
RewriteBase / | |
rewritecond %{http_host} ^domain.com [nc] | |
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] | |
#Redirect to www location with subdirectory | |
RewriteEngine on | |
RewriteBase / | |
RewriteCond %{HTTP_HOST} domain.com [NC] | |
RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC] | |
#Redirect from old domain to new domain with full path and query string: | |
Options +FollowSymLinks | |
RewriteEngine On | |
RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC] | |
#Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string: | |
Options +FollowSymLinks | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$ | |
RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC] | |
Rewrite and redirect URLs with query parameters (files placed in root directory) | |
Original URL: | |
http://www.example.com/index.php?id=1 | |
Desired destination URL: | |
http://www.example.com/path-to-new-location/ | |
.htaccess syntax: | |
RewriteEngine on | |
RewriteCond %{QUERY_STRING} id=1 | |
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301] | |
Redirect URLs with query parameters (files placed in subdirectory) | |
Original URL: | |
http://www.example.com/sub-dir/index.php?id=1 | |
Desired destination URL: | |
http://www.example.com/path-to-new-location/ | |
.htaccess syntax: | |
RewriteEngine on | |
RewriteCond %{QUERY_STRING} id=1 | |
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301] | |
Redirect one clean URL to a new clean URL | |
Original URL: | |
http://www.example.com/old-page/ | |
Desired destination URL: | |
http://www.example.com/new-page/ | |
.htaccess syntax: | |
RewriteEngine On | |
RewriteRule ^old-page/?$ $1/new-page$2 [R=301,L] | |
Rewrite and redirect URLs with query parameter to directory based structure, retaining query string in URL root level | |
Original URL: | |
http://www.example.com/index.php?id=100 | |
Desired destination URL: | |
http://www.example.com/100/ | |
.htaccess syntax: | |
RewriteEngine On | |
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA] | |
Rewrite URLs with query parameter to directory based structure, retaining query string parameter in URL subdirectory | |
Original URL: | |
http://www.example.com/index.php?category=fish | |
Desired destination URL: | |
http://www.example.com/category/fish/ | |
.htaccess syntax: | |
RewriteEngine On | |
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA] | |
Domain change – redirect all incoming request from old to new domain (retain path) | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC] | |
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] | |
If you do not want to pass the path in the request to the new domain, change the last row to: | |
RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L] | |
#From blog.oldsite.com -> www.somewhere.com/blog/ | |
retains path and query, and eliminates xtra blog path if domain is blog.oldsite.com/blog/ | |
Options +FollowSymLinks | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI}/ blog | |
RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC] | |
RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC] |
Drive Zone Online Unlimited Money lets players enjoy the game without financial restrictions, allowing unlimited customization, car upgrades, and premium features. This version enhances the gameplay experience by unlocking all cars and accessories.
Using Lulubox Pro APK, players can enjoy ad-free gaming, ensuring an uninterrupted experience.
Lulubox Pro APK allows users to manage multiple game accounts on the same device with ease.
Great post. You can download the Game lost life apk from the website https://lostlife.vip/ official website of the game.
The Jollibee Mix and Match Menu is a great way to enjoy your favorite meals at an affordable price. It gives customers the flexibility to customize their meals by choosing from different options, making it a budget-friendly and convenient choice. Perfect for those who love variety without spending too much! 🍔🍗😊
This is a comprehensive guide on implementing 301 redirects using .htaccess extremely useful for SEO and maintaining site structure during domain changes or updates! If you’re looking for reliable plumbing services to keep your home’s systems running smoothly, check out my plumbing site at Plumbers Near Me . We’re here to help with all your plumbing needs, just like this guide helps with redirects!
Check Your VAT From Calcvat.
https://ytmp3mate.com youtube video downloader
Support Full HD, 1080p, 2k, 4k
Looking for an easy way to enhance your brand’s visibility? custom hoodies are a stylish solution. Embroidered and printed designs create a professional look. Soft, high-quality materials provide all day comfort. Employees and customers love wearing branded apparel. Get high-quality customised hoodies to showcase your business.
يُعتبر GitHub منصة رائدة لمشاركة الأكواد والمشاريع البرمجية بين المطورين، تمامًا كما تُعد لعبة طاولة بلوت وسيلة ممتعة للتفاعل والتعاون بين الأصدقاء والعائلة.
GTA San Andreas APK (gtasanapks.com) remains one of the most popular open-world action games for Android, offering a nostalgic yet thrilling experience. The latest APK version brings improved graphics, smoother controls, and enhanced compatibility with modern devices. Rockstar Games has optimized gameplay performance, fixing previous bugs and ensuring better stability. Players can explore the vast map of San Andreas, complete missions, and enjoy classic cheat codes for extra fun. With continued fan support, GTA San Andreas APK remains a timeless masterpiece in mobile gaming.
Visit https://beingfiler.com/cm-punjab-asaan-karobar-finance-asaan-karobar-card/ to get complete details about CM Punjab Asaan Karobar Finance and Asaan Karobar Card. Learn about eligibility, benefits, and the application process in one place
Smart SIM Card registration in the Philippines can be sometimes tricky for applicants. To make this process smooth and easy an applicant should See information here
Instander can make your Instagram experience worth even more than you expected. It can add more control be adding MOD features in it. Check now which features can be your most favorite one
Great resource! Managing clinical trial sites efficiently is crucial for successful research. At Site Management Organization , we specialize in SMO services
Informative, If you have any plans to play Hero Games Then you should download and play Rope Hero MOD APK
Looking for the safest way to play Infinity Brawl? Download from infinitybrawl.com and unlock the best features, including unlimited gems, powerful heroes, and exciting game modes. Experience a seamless and action-packed gaming experience today.
Fantastic post! I truly enjoyed your perspective—it’s refreshing to see how traditional elements are being reinterpreted in modern design. The evolution of water pipes, in particular, is fascinating. I recently explored some innovative designs from Lotus Glass USA, where they blend artistry with functionality in remarkable ways. It’s exciting to see how craftsmanship and cutting-edge techniques are shaping the aesthetics and performance of these pieces. Your insights have sparked my curiosity to delve deeper into this evolution, and I’d love to see more discussions on this in future posts. Keep up the great work!
The 8 Ball Pool Mod APK makes the game so much more enjoyable with unlimited coins and cash. It’s a game-changer for leveling up quickly.
Check out the latest Irish Lotto results. The winning numbers of the Irish Lottery draws are live within minutes every Wednesday and Saturday (T&Cs Apply)
Informative...
Great post! The information is well-explained and very useful. It’s always helpful to see practical examples like this. Do you think this method works best for beginners, or is it more suited for advanced users? Also, if anyone is interested in growing their Instagram with free followers and likes, Instaup mod APK is a great tool to check out. Looking forward to more insights like this!
Looking to streamline your HR operations? Partner with the Best HR Outsourcing Provider in Pakistan for end-to-end HR solutions, including payroll, compliance, and workforce management, so you can focus on business growth.
Jeem.pk has earned a reputation for excellent customer service, addressing queries and issues promptly. The support team is dedicated to ensuring a smooth shopping experience for all users. This focus on customer satisfaction strengthens its reputation. https://www.jeem.pk/
Enjoy the ultimate volleyball challenge with The Spike Game. Designed for all platforms, it brings smooth controls, stunning graphics, and competitive gameplay. Whether you're practicing alone or competing with others, every match is filled with action. Join the fun now at The Spike Game.
These are useful .htaccess redirects for domain migrations, subfolder structuring, and query parameter handling. Be careful with rules to avoid redirect loops and unintended behavior. i Test it before applying site-wide. cookssimplepainting
It looks like you need .htaccess redirect rules for specific scenarios. Could you clarify what exactly you want to achieve? Are you looking to:
Redirect an old domain to a new one?
Redirect specific pages or URLs?
Redirect non-www to www (or vice versa)?
Handle query string-based redirects?