Trying to redirect blog.domain.com to www.domain.com/blog/

I'm combining a main site at www.domain.com, and an old wordpress blog at blog.domain.com, into one completely new Wordpress install. I have exported and imported all the old blog posts so that they now live under wwww.domain.com/blog//

I am trying to create one rewrite rule that will map all the old blog posts to their new URLS.

I've tried variations on these SO discussions: DNS/.htaccess files to redirect subdomain to specific folder Apache rewrite rule different if capture is empty

but nothing is working.

The following in my .htaccess file will redirect blog.domain.com to www.domain.com/blog, if there is nothing more in the URL:

RewriteCond %{HTTP_HOST} ^blog\.domain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.blog\.domain\.com$ [NC]
RewriteRule ^/?$ http://www.domain.com/blog/$1 [R=301,L]

but if there is anything more in the URL, it does not rewrite the URL at all, and goes to the new Wordpress site's 404 page.

I tried adding a capture to the final RewriteRule line, but then no rewrite occurs, and it just goes to the new homepage but the address bar still reads "blog.domain.com":

RewriteCond %{HTTP_HOST} ^blog\.domain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.blog\.domain\.com$ [NC]
RewriteRule ^/(.+)$ http://www.domain.com/blog/$1 [R=301,L]

Is there a way to do what I'm trying to do?

django file upload: [Errno 13] Permission denied: ‘/static’

I am trying to upload several files in django. On my local maching where I use the djangos build in server everything works fine but on my productivity server I get this error:

[Errno 13] Permission denied: '/static'

There are many questions about this issue but nothing I found worked for me. In my case it has nothing to do with file permissions. I found out that the problem is that django want save the files in the root folder of my filesystem and not in the root folder of my website. If I create the folder in '/static' the files will be created there but images for example are not shown on the webpage because django expects them in '/var/www/webpage-root/static/...'

I use a model to store files:

class Document(models.Model):
    title = models.CharField(max_length=100, blank=True, null=False)
    document = models.FileField(upload_to='static/bachelor/documents/', max_length=500, blank=True, null=True)

and save them in this way:

if form.is_valid():
    data = request.FILES['document']
    doc = Document(document=data)
    doc.save()

As described there: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/

I use Apache and mod_wsgi. The apache file looks like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName webpage.de
    ServerAlias www.webpage.de
    DocumentRoot /var/www/webpage

    Alias /media /var/www/webpage/webpage/
    Alias /static /var/www/webpage/static/

    <Directory /var/www/webpage>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias / /var/www/webpage/apache/webpage.wsgi
    <Directory /var/www/webpage>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/webpage-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/webpage-access.log combined
</VirtualHost>

The settings file of my website:

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    '/var/www/website/static/',
    '/home/michael/Development/website/static/',
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

I had to set two different paths in STATICFILES_DIRS because I already had problems to serve static files on my server. With this two lines I can serve static files on both ends, on my development machine and my public server runnig apache.

Did I miss something in my configuration or is there something wrong? I dont know why apache wants upload the files in /static instead of /var/www/website/static but I think it can be because of a problem with my apache configuration...

Has anyone an idea or can help me please?

Thank you much

django file upload: [Errno 13] Permission denied: ‘/static’

I am trying to upload several files in django. On my local maching where I use the djangos build in server everything works fine but on my productivity server I get this error:

[Errno 13] Permission denied: '/static'

There are many questions about this issue but nothing I found worked for me. In my case it has nothing to do with file permissions. I found out that the problem is that django want save the files in the root folder of my filesystem and not in the root folder of my website. If I create the folder in '/static' the files will be created there but images for example are not shown on the webpage because django expects them in '/var/www/webpage-root/static/...'

I use a model to store files:

class Document(models.Model):
    title = models.CharField(max_length=100, blank=True, null=False)
    document = models.FileField(upload_to='static/bachelor/documents/', max_length=500, blank=True, null=True)

and save them in this way:

if form.is_valid():
    data = request.FILES['document']
    doc = Document(document=data)
    doc.save()

As described there: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/

I use Apache and mod_wsgi. The apache file looks like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName webpage.de
    ServerAlias www.webpage.de
    DocumentRoot /var/www/webpage

    Alias /media /var/www/webpage/webpage/
    Alias /static /var/www/webpage/static/

    <Directory /var/www/webpage>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias / /var/www/webpage/apache/webpage.wsgi
    <Directory /var/www/webpage>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/webpage-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/webpage-access.log combined
</VirtualHost>

The settings file of my website:

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    '/var/www/website/static/',
    '/home/michael/Development/website/static/',
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

I had to set two different paths in STATICFILES_DIRS because I already had problems to serve static files on my server. With this two lines I can serve static files on both ends, on my development machine and my public server runnig apache.

Did I miss something in my configuration or is there something wrong? I dont know why apache wants upload the files in /static instead of /var/www/website/static but I think it can be because of a problem with my apache configuration...

Has anyone an idea or can help me please?

Thank you much

django file upload: [Errno 13] Permission denied: ‘/static’

I am trying to upload several files in django. On my local maching where I use the djangos build in server everything works fine but on my productivity server I get this error:

[Errno 13] Permission denied: '/static'

There are many questions about this issue but nothing I found worked for me. In my case it has nothing to do with file permissions. I found out that the problem is that django want save the files in the root folder of my filesystem and not in the root folder of my website. If I create the folder in '/static' the files will be created there but images for example are not shown on the webpage because django expects them in '/var/www/webpage-root/static/...'

I use a model to store files:

class Document(models.Model):
    title = models.CharField(max_length=100, blank=True, null=False)
    document = models.FileField(upload_to='static/bachelor/documents/', max_length=500, blank=True, null=True)

and save them in this way:

if form.is_valid():
    data = request.FILES['document']
    doc = Document(document=data)
    doc.save()

As described there: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/

I use Apache and mod_wsgi. The apache file looks like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName webpage.de
    ServerAlias www.webpage.de
    DocumentRoot /var/www/webpage

    Alias /media /var/www/webpage/webpage/
    Alias /static /var/www/webpage/static/

    <Directory /var/www/webpage>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias / /var/www/webpage/apache/webpage.wsgi
    <Directory /var/www/webpage>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/webpage-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/webpage-access.log combined
</VirtualHost>

The settings file of my website:

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    '/var/www/website/static/',
    '/home/michael/Development/website/static/',
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

I had to set two different paths in STATICFILES_DIRS because I already had problems to serve static files on my server. With this two lines I can serve static files on both ends, on my development machine and my public server runnig apache.

Did I miss something in my configuration or is there something wrong? I dont know why apache wants upload the files in /static instead of /var/www/website/static but I think it can be because of a problem with my apache configuration...

Has anyone an idea or can help me please?

Thank you much

django file upload: [Errno 13] Permission denied: ‘/static’

I am trying to upload several files in django. On my local maching where I use the djangos build in server everything works fine but on my productivity server I get this error:

[Errno 13] Permission denied: '/static'

There are many questions about this issue but nothing I found worked for me. In my case it has nothing to do with file permissions. I found out that the problem is that django want save the files in the root folder of my filesystem and not in the root folder of my website. If I create the folder in '/static' the files will be created there but images for example are not shown on the webpage because django expects them in '/var/www/webpage-root/static/...'

I use a model to store files:

class Document(models.Model):
    title = models.CharField(max_length=100, blank=True, null=False)
    document = models.FileField(upload_to='static/bachelor/documents/', max_length=500, blank=True, null=True)

and save them in this way:

if form.is_valid():
    data = request.FILES['document']
    doc = Document(document=data)
    doc.save()

As described there: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/

I use Apache and mod_wsgi. The apache file looks like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName webpage.de
    ServerAlias www.webpage.de
    DocumentRoot /var/www/webpage

    Alias /media /var/www/webpage/webpage/
    Alias /static /var/www/webpage/static/

    <Directory /var/www/webpage>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias / /var/www/webpage/apache/webpage.wsgi
    <Directory /var/www/webpage>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/webpage-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/webpage-access.log combined
</VirtualHost>

The settings file of my website:

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    '/var/www/website/static/',
    '/home/michael/Development/website/static/',
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

I had to set two different paths in STATICFILES_DIRS because I already had problems to serve static files on my server. With this two lines I can serve static files on both ends, on my development machine and my public server runnig apache.

Did I miss something in my configuration or is there something wrong? I dont know why apache wants upload the files in /static instead of /var/www/website/static but I think it can be because of a problem with my apache configuration...

Has anyone an idea or can help me please?

Thank you much

Call to undefined function pg_connect() – Wamp

I want to connect to PostgreSQL, Im using wamp 64 bit.

I have here

  • Apache 2.4.2
  • PHP 5.4.3
  • Mysql 5.5.24

I also uncomment in php.ini the php_pgsql and php_pdo_pgsql. but i can't connect , It gives me error like this :

Error suppression ignored for ( ! ) Fatal error: Call to undefined function pg_connect()

Is there anybody know the solution regarding on my problem. I just need it badly.

Thank you .

Why won’t Apache start in XAMPP installation?

I've taken the first steps to learning PHP - think it would be a good step in the right direction. I would like some help however on installing XAMPP. I have downloaded the file and all that through the Apache Friends site, but when I head to to control panel, I get numerous errors.

This is what it says for me:

**10:21:53  [Apache]    Problem detected!
10:21:53  [Apache]  Port 80 in use by "Unable to open process" with PID 4!
10:21:53  [Apache]  Apache WILL NOT start without the configured ports free!
10:21:53  [Apache]  You need to uninstall/disable/reconfigure the blocking application
10:21:53  [Apache]  or reconfigure Apache and the Control Panel to listen on a different port
10:21:53  [Apache]  Problem detected!
10:21:53  [Apache]  Port 443 in use by "C:\Program Files (x86)\Skype\Phone\Skype.exe" with PID 3748!
10:21:53  [Apache]  Apache WILL NOT start without the configured ports free!
10:21:53  [Apache]  You need to uninstall/disable/reconfigure the blocking application
10:21:53  [Apache]  or reconfigure Apache and the Control Panel to listen on a different port
10:21:53  [main]    Starting Check-Timer
10:21:53  [main]    Control Panel Ready**

Could someone please tell me what this means and how I remedy it? Thanks very much.

How to Set AllowOverride all

I want to set the AllowOverride all But I don't know how to do it. I have found the following code by searching the google and pasted it in .htaccess

<Directory>
        AllowOverride All
</Directory>

But after pasting it I started receiving "Internal Server Error"

Can Any One Guide Me Where to Put this code OR how to do it?

HOW TO: Set up a Virtual Host on Apache 2.4.4 [ MAC / *NIX ]

I am posting this because I recently had a lot of trouble setting up a Virtual Host with a MAMP stack, due to Apple's throttling of the useable PHP version on Mac OS 10.8's default Apache2 installation.

This is a very quick guide on what to do and I owe the solution to this question on Stack Overflow:

You can think of this as a compilation of what worked for me, as the accepted answers had no effect, but rather those with a significantly lower score.

Similarly, every guide I have seen fails to mention some points which users answered with on the sourced question.

rake assets:precompile every time I edit CSS?

When I looked at the HTML source for my main page, the CSS that Rails was linking to was in /stylesheets/application.css. When I tried to click that link, I would get a 404 not found error from Passenger (Apache).

So what ended up working was setting config.assets.compile = true in my config file and running rake assets:precompile. This then changed the CSS link to something like /assets/application-5310fa2adccd74453c084cf221eaeeef.css, and this was something I could click on and could be found.

So now what I'm doing is every time I edit my CSS file, I run precompile. Is this the correct way to do things? Do I really have to call this every time I edit my CSS file? Is this the purpose of precompiling, to make sure my assets are able to be served by Apache?