Category Archives: alias

htaccess multidomain with WordPress

I want migrate Website on wordpress from old web hosting to new web hosting.

My new hosting provider allows extra domain (alias) like this

www/domains/domain1.com

www/domains/domain2.com

My root directory on the new hosting:

/

-.htaccess

-session

-tmp

-www/domains/my-domain.com/wordpressfolder

I have problem with error when I used internal web address(myinternaladdress.hosting.com) from my new hosting to test if everthing work before I route my domain to new hosting.

In Wordpress I set wp-config.php WP_HOME,WP_SITEURL,WP_HOME,WP_SITEURL to

"myinternaladdress.hosting.com/www/domains/my-domain.com/"

.htaccess file in www directory:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^domains/
RewriteCond %{REQUEST_URI} !^/domains/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$
RewriteCond %{DOCUMENT_ROOT}/domains/%2 -d
RewriteRule (.*) domains/%2/$1 [DPI]
RewriteCond %{REQUEST_URI} !^subdom/
RewriteCond %{REQUEST_URI} !^/subdom/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/subdom/%2 -d
RewriteRule (.*) subdom/%2/$1 [DPI]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^domains/[^/]+/(.+[^/])$ /$1/ [R]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^subdom/[^/]+/(.+[^/])$ /$1/ [R]

.htaccess file in Wordpress directory

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

When I go to myinternaladdress.hosting.com/www/domains/my-domain.com/ main page work well but e.g. /my-domain.com/about/ not found.

Apache configure virtual host for multiple directories

I have my site under /var/www/html/v1/public but in future I will have /var/www/html/v2/public and so on and they will be accessed over mydomain.com/v1, mydomain.com/v2 etc.

It's been ages since I last configured a web server so go easy on me. I figured mod_rewrite is the way to go so I have a single virtual host like this:

ServerAdmin [email protected]
ServerName mydomain.com

DocumentRoot /var/www/html/

RewriteEngine On
RewriteRule ^(v\d+)/(.*)$ "$1/public/$2"

Which still requires me to go mydomain.com/v1/public. I also tried using an alias

ServerAdmin [email protected]
ServerName mydomain.com

#DocumentRoot /var/www/html/
AliasMatch ^/v(\d+) /var/www/html/v$1/public

#RewriteEngine On
#RewriteRule ^(v\d+)/(.*)$ "$1/public/$2"

Which tells me I've exceeded the internal recursion limit.

This looks really simple to do but I'm failing miserably at it..

Domain alias in xampp

I'm trying to place a domain alias named noetic.dev, I'm having a fresh laravel installation in the htdocs folder named noetic.

For achieving this I tried to change httpd.conf file and added this:

Alias /noetic.dev "F:/xamp/htdocs/Noetic/public/" 

<Directory "F:/xamp/htdocs/Noetic/public/">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride all
  Require local
</Directory>

and I changed following in httpd-vhosts.conf:

<VirtualHost *:8082>
    ServerName noetic.dev
    DocumentRoot c:/wamp/www/NitsEdit/public
</VirtualHost>

and similarly I've in the hosts file:

127.0.0.1       noetic.dev

Now while trying the link to be as http://localhost:8082/noetic.dev/ I'm getting the result but while trying noetic.dev:8082 I'm getting an error

Access forbidden: You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.

I don't know where I'm doing wrong, guide me in this.

Alias apache with requested URL?

If I write in the settings: Alias /blog2/ "/path_to_other/www/" The script will be run from the root directory as / (as root) But I need it with requested url -> /blog2 Now, to get /blog2 I need to write: /blog2/blog2 Option Alias /blog2/ "/path_to/www/blog2/" is not working

I have two folders: 1. Main folder with index.php 2. Another folder with index.php. All requests should go to folder N1, except /blog2/../.. But script in folder N2 should get the full url -> /blog2/../.. I set Alias /blog2 "/path_to/www/blog2" and now it gets /../.. (without leading /blog2). Yes, I tried RewriteRule ^/blog2 /blog2/blog2 [NC,L] Not working too

PHP apache document root need to create an alias for url resolution

So I inherited some PHP code.

  1. I installed XAMPP on my windows machine
  2. I changed the DocumentRoot and Directory paths to

    C:\dev\CustomCloud\prod 
    

However, now when I visit localhost I see tons of 404 errors

Seems the PHP code is trying to resolve an ALIAS of localhost/matchmaking/

Example:

  C:\dev\CustomCloud\prod\assets

Is

http://localhost/matchmaking/assets/

What is the best or easiest solution to resolve this as I rarely work with PHP, but I need Apache to serve up this code locally so I can work with the code a bit etc...

How can I set a subdirectory as a SeverAlias for WP Multisite?

When setting up a site to use WP multisite I alter the httpd.conf file as such:

<VirtualHost *:80>
    DocumentRoot /home/www/dev.mywpsite.com
    ServerName dev.mywpsite.com
    ServerAlias anewsite.com
    ServerAlias www.anewsite.com
</VirtualHost>

in this example anewsite.com is a mapped domain on WP multisite. This also works fine for subdomains sub.anewsite.com. However I need to do this with a subdomain such as anewsite.com/sub but this doesn't work. When I restart httpd.conf I don't get errors but it also has no effect.

It tried going to the virtualhost record for anewsite.com and setting up:

<VirtualHost *:80>
    DocumentRoot /home/www/anewsite.com
    ServerName anewsite.com

    Alias /sub /home/www/dev.mywpsite.com
    <Directory /home/www/dev.mywpsite.com>
        ...
    </Directory>
</VirtualHost>

But that acted like a redirect and not an alias.

Why error 403 when using alias and not redirect directives in apache2 server config?

I am new to apache and webservers in general but I have a problem with accessing phps with alias URLs from the web. This is what my config looks like:

ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com

AliasMatch "^/index$" "/"
AliasMatch "^/about$" "/about.php"
AliasMatch "^/editor$" "/editor.php"

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

The php files that I want to display are located in DocumentRoot folder, and I've made sure root and all its subdirectories and files have permissions 755. What confuses me is that instead of Alias I use Redirect it works fine, except that the browser URL field shows .php which is not desirable. So how come permission is not granted with aliasing but with redirecting? Below is a log entry of attempting to access with site conf file as written above:

127.0.0.1 - - [27/Jan/2017:04:11:55 +0100] "GET /about HTTP/1.1" 403 422 "http://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"

Any help is appreciated, Cheers

Alias implementation in mod_rewrite apache

I have the below queries on alias implementation of mod_rewrite in apache:

  1. Is alias evaluated for all the flags or only for [PT] flag ?
  2. Does alias represent only the target (or substitution string) in a RewriteRule ?
  3. Is the flow correct : source url mentioned in the rewrite rule matched the incoming url >> before replacing with the target check for an alias match >> if alias match found then evaluate the alias else keep the target as is and do the redirection

Apache 2.4: application.com also at domain.com/application, how?

I have an application that lives at "application.com" and I need to be able to access it from "domain.com/application", with the URL also updating depending on how the application is accessed. How would I do this? I've been trying to use the alias directive and it seems to half-way get me there but I'm definitely missing something, I just don't know what. Could someone point me in the right direction with this? Thanks a lot.

Apache: 2.4 PHP 5.6