ASP.NET Basic URL Rewriting or code in master page
You could redirect your previous URLs to a new location just using your web.config file.
This is an example of redirecting a URL to another location in the Web.config file:
<system.webServer>
<rewrite>
<rule name="redirect to sign-in" stopProcessing="true">
<match url="previous-folder/SignIn.aspx"/>
<action type="Redirect" url="http://newWebSite.com/SignIn.aspx" redirectType="Permanent"/>
</rule>
</rewrite>
</system.webServer>
Is there something wrong with my rewrite code in .htaccess file
After a lot of painstaking experimentation the problem has at last been solved.
It seems that with the new iis8.5 server and Helion Ape I needed to put the rewrite rules into a web.config file instead of a .htaccess file.
The new rule for the example I gave in the question is:
<rule name="Imported Rule 6">
<match url="^uk-bed-breakfast-(.*)\.htm" ignoreCase="false" />
<action type="Rewrite" url="/bed-and-breakfast/region.asp?county={R:1}" appendQueryString="true" />
</rule>
Using this system the website is at last functioning correctly.
Many thanks to all who tried to help.
Tog
URL rewrite in ASP.net for multi language
Do you have access to a .htaccess
file in your home directory? If so, you can make an automatic rewrite rule by writing the following
Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/contact-us/ /Pages/Contact.aspx?language=$1
RewriteRule /contact-us/ /Pages/Contact.aspx?language=en
Let me explain:
After RewriteRule
, the user-friendly URL is on the left, here /(.*)/contact-us/
where (.*)
is where jp
will take place.
Then that jp
is transposed on the real URL on the right, here /Pages/Contact.aspx?language=$1
to replace $1
.
Input URL: http://www.example.com/jp/contact-us
Output URL: http://www.example.com/Pages/Contact.aspx?language=jp
For the second RewriteRule
, as the URL http://www.example.com/contact-us/
does not match the first model, it will turn into http://www.example.com/Pages/Contact.aspx?language=en
automatically.
Please remember that the .htaccess
file MUST be in the root directory (alongside Pages
folder). Otherwise you will not get the desired result.
Related Topics
Use Curly Brackets to Structure Code in PHP
PHP Localization Best Practices? Gettext
Output Text File with Line Breaks in PHP
How to Set the Cookie Content with Curl
Laravel 5.5 Error Base Table or View Already Exists: 1050 Table 'Users' Already Exists
PHP Warning: Exec() Unable to Fork
How to Select Multiple Rows from MySQL with One Query and Use Them in PHP
PHP Run Once and Insert Twice in MySQL Database
Get the Hierarchy of a Directory with PHP
Using Fetch_Assoc on Prepared Statements
Php: Check for Duplicate Values in a Multidimensional Array
3Rd Party Dependency Conflict in Developing Wordpress Plugin
How to Prevent from Printscreen of My Webpage
How to Paginate Lines in a Foreach Loop with PHP
PHP Curly Braces in Array Notation
PHP - Merge Two Arrays (Same-Length) into One Associative