I've been working with my .htaccess file and mod_rewrite for a couple of days now trying to create a rule that allows people to point their own domains to paths of my website.
i.e. they have created a landing page on my website, located at www.website.com/landingPages/myUniqueWebsite
and they would like to point their domain, www.myuniquewebsite.com to that url above.
Could anyone suggest what apache rule to use to accomplish this?
My .htaccess currently looks like this:
# disallow access to any directories without an index file
Options -Indexes
RewriteEngine on
# remove trailing slash
RewriteRule ^(.*)/$ /myProject/$1 [L,R=301]
FallbackResource ../appContent/BasePage.php
Where the BasePage above takes the directory data from the URL and gets the users landing page data from the db.
Also should they be using domain pointing or aliasing in their hosting provider dashboard?
Related
So I have this website: www.example.com, which in the past would redirect the clients to www.example.com/subdir
Now I updated the whole site, and the subdirectory doesn't exist anymore, and I want the main domain to be the root. The problem is that many clients have cached the url with the subdomain included, so I need a redirection rule to route www.example.com/subdir to www.example.com.
I tried this:
RewriteRule ^subdir/(.*)$ $1
which works if I enter www.example.com/subdir/ with the last slash
but if I access www.example.com/subdir without last slash it won't do the job.
How can I make it work?
Change your rule to this:
RewriteRule ^subdir(?:/(.*))?$ /$1 [L,NC,R=301,NE]
It is important to use R=301 here so that all clients and search engines eventually move to new URL rather than keep using duplicate URL for the same content (bad SEO).
I am trying to make a .htaccess file that is basically a wildcard setup. I have a folder structure as below.
public_html/sites is the root directory and in this folder there are two sub directories:
public_html/sites/brand (there are many brand folders, just used brand as example)
public_html/sites/brand/event (there are many events in a brand folder, just used event as example)
I have files in each event folder such as index.php and media.php
I have been unsuccessful in rewriting the media page to the URL structure I am looking for. Below is my current .htaccess file.
RewriteEngine On
RewriteRule ^media/([^/]*)$ /media.php?unqid=$1 [L]
So the expected URL I am wanting is /testbrand/4177/media/123456. I will have serveral brands and several events under each brand so I am needing some sort of wildcard if possible. Any help is appreciated. Thanks in advance.
If you are wanting to have a URL like this
http://example.com/testbrand/4177/media/123456
And your brands are dynamic, then your rewrite should probably look something like this.
RewriteRule ^(?:[^/]+)/(?:[0-9]+)/media/([0-9]+)/?$ /media.php?unqid=$1 [L]
Based on your current internal URL you'll only be sending the id number that comes after /media/ to PHP. If you have more info you need to send, then you need to update your internal URI parameters.
You can use this rule in your root .htaccess:
RewriteEngine On
RewriteRule ^([^/]+/[^/]+)/media/(\d+)/?$ $1/media.php?unqid=$2 [L,NC,QSA]
This will load /testbrand/4177/media.php?unqid=123456 when you request /testbrand/4177/media/123456
My host provider has CFWheels set up as the root www folder I can access. However, I am trying to add a folder that is independent of the framework. In folder foo/ I added a blank application.cfc as told here in the folder. But, when I upload the folder and try to view it on mywebsite.com/foo I get
Could not find the view page for the index action in the Admin controller.
Could the host have disabled my ability to do this? I also read that you can place files you don't want CFWheels to affect by adding them to miscellaneous/ but want to avoid that if possible.
Two things to check:
1) Have you excluded 'foo' in any URL rewriting files - i.e, .htaccess (apache etc) or web.config (IIS etc)? If you add it there it will bypass wheels easily.
i.e:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*/(foo|flex2gateway|jrunscripts|cfide|cfformgateway|CFFileServlet|cffileservlet|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$) [NC]
RewriteRule ^(.*)$ ./rewrite.cfm/$1 [NS,L]
2) If you're not using url rewriting, then it might be there's a catchall route in your config/routes.cfm file.
Do you have anything with a wildcard there?
i.e
addRoute(name="catchall", pattern="*", controller="admin", action="index");
Try putting some content in your /foo/Application.cfc file.
component {
this.name = "foo";
}
Also, make sure the file name starts with a capital "A" - case matters on Unix/Linux servers.
We have our company websites and in that we have careers tab . All files of our company website are placed into a root folder.So for different career openings we created different pages which are being placed inside the root folder for e.g http:/mycompany.com/androidDeveloper.php.But now we want url to look differently i.e .When androidDeveloper.php is openned in Url I want it to be seen as http:/mycompany.com/Careers/androidDeveloper.php but I don't want to create new directory as mycompany.com/careers in my root directory is there any way where in above mentioned can be possible
I tried doing this in .htaccess file but doesn't seems to work
Redirect http://mycompany.com/androidDeveloper.php http://mycompany.com/careers/androidDeveloper.php
You can try this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^careers(/.*)?$ $1 [L,NC]
I'm using wordpress.
I'd like my site's domain root to display contents of another page while still showing my domain root as the url.
EXAMPLE: "http://www.mysite.com" displays contents of "http://www.mysite.com/blogs/home"
but users still see "http://www.mysite.com" in the address bar.
I've managed to get the redirect working, but it's not masking the URL. It essentially is redirecting.
Here's what I have now in my htaccess:
RewriteEngine on
RewriteRule ^\/?$ \/blogs\/home\/ [R,NC]
The R option forces an external redirect. Try just [NC] instead
what about this way.
put the index.php and .htaccess file in the root of your domain.
edit index.php to grab the "wp-blog-header.php" file from what ever location you put it. For example, if your wordpress file is located in blogs/home/ sub directory, you change the index.php file located in the root directory as require('./blogs/home/wp-blog-header.php').
forget about the redirect issue.
I think this is the easiest way. Or did I misunderstand your question?
There is a very simple solutions to this problem. In fact wordpress has an option to accomplish this task.
Go to Dashboard->Settings->Reading->Front page displays
Select a static page as front page.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^$ /blogs/home [NC,P]
PS: Make sure you have mod_proxy enabled in your Apache config.